MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / WaitForRESTAPIs

Method WaitForRESTAPIs

rest/server_context.go:214–229  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

212}
213
214func (sc *ServerContext) WaitForRESTAPIs(ctx context.Context) error {
215 timeout := 30 * time.Second
216 interval := time.Millisecond * 100
217 numAttempts := int(timeout / interval)
218 ctx, cancelFn := context.WithTimeout(ctx, timeout)
219 defer cancelFn()
220 err, _ := base.RetryLoop(ctx, "Wait for REST APIs", func() (shouldRetry bool, err error, value interface{}) {
221 sc._httpServersLock.RLock()
222 defer sc._httpServersLock.RUnlock()
223 if len(sc._httpServers) == len(allServers) {
224 return false, nil, nil
225 }
226 return true, nil, nil
227 }, base.CreateSleeperFunc(numAttempts, int(interval.Milliseconds())))
228 return err
229}
230
231// getServerAddr returns the address as assigned by the listener. This will return an addressable address, whereas ":0" is a valid value to pass to server.
232func (sc *ServerContext) getServerAddr(s serverType) (string, error) {

Callers 3

StartServerWithConfigFunction · 0.80
DevTestFetchConfigManualFunction · 0.80

Calls 4

RetryLoopFunction · 0.92
CreateSleeperFuncFunction · 0.92
RLockMethod · 0.80
RUnlockMethod · 0.80

Tested by 2

DevTestFetchConfigManualFunction · 0.64