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

Function WithTimeout

db/database.go:2140–2146  ·  view source on GitHub ↗

TIMEOUTS Calls a function, synchronously, while imposing a timeout on the Database's Context. Any call to CheckTimeout while the function is running will return an error if the timeout has expired. The function will *not* be aborted automatically! Its code must check for timeouts by calling CheckTim

(ctx context.Context, timeout time.Duration, operation func(tmCtx context.Context) error)

Source from the content-addressed store, hash-verified

2138// Calls a function, synchronously, while imposing a timeout on the Database's Context. Any call to CheckTimeout while the function is running will return an error if the timeout has expired.
2139// The function will *not* be aborted automatically! Its code must check for timeouts by calling CheckTimeout periodically, returning once that produces an error.
2140func WithTimeout(ctx context.Context, timeout time.Duration, operation func(tmCtx context.Context) error) error {
2141 newCtx, cancel := context.WithTimeout(ctx, timeout)
2142 defer func() {
2143 cancel()
2144 }()
2145 return operation(newCtx)
2146}
2147
2148// Returns an HTTP timeout (408) error if the Database's Context has an expired timeout or has been explicitly canceled. (See WithTimeout.)
2149func CheckTimeout(ctx context.Context) error {

Callers 2

handleFunctionCallMethod · 0.92
handleFunctionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected