MCPcopy Create free account
hub / github.com/openclaw/gogcli / openKeyringWithTimeoutFunc

Function openKeyringWithTimeoutFunc

internal/secrets/backend.go:340–363  ·  view source on GitHub ↗

openKeyringWithTimeoutFunc prevents an unresponsive SecretService open from blocking the CLI indefinitely. The worker goroutine may remain blocked until process exit after a timeout.

(
	cfg keyring.Config,
	timeout time.Duration,
	hint string,
	open func(keyring.Config) (keyring.Keyring, error),
)

Source from the content-addressed store, hash-verified

338// blocking the CLI indefinitely. The worker goroutine may remain blocked until
339// process exit after a timeout.
340func openKeyringWithTimeoutFunc(
341 cfg keyring.Config,
342 timeout time.Duration,
343 hint string,
344 open func(keyring.Config) (keyring.Keyring, error),
345) (keyring.Keyring, error) {
346 ch := make(chan keyringResult, 1)
347
348 go func() {
349 ring, err := open(cfg)
350 ch <- keyringResult{ring, err}
351 }()
352
353 select {
354 case res := <-ch:
355 if res.err != nil {
356 return nil, fmt.Errorf("open keyring: %w", res.err)
357 }
358
359 return res.ring, nil
360 case <-time.After(timeout):
361 return nil, keyringTimeoutError("opening keyring", timeout, hint)
362 }
363}
364
365func Open(options OpenOptions) (Repository, error) {
366 ring, err := openKeyringWithOptions(options)

Calls 2

keyringTimeoutErrorFunction · 0.85
ErrorfMethod · 0.80