MCPcopy Index your code
hub / github.com/coder/coder / clientDoWithRetries

Function clientDoWithRetries

provisionerd/provisionerd.go:477–493  ·  view source on GitHub ↗

clientDoWithRetries runs the function f with a client, and retries with backoff until either the error returned is not retryable() or the context expires.

(ctx context.Context,
	getClient func() (proto.DRPCProvisionerDaemonClient, bool),
	f func(context.Context, proto.DRPCProvisionerDaemonClient) (T, error),
)

Source from the content-addressed store, hash-verified

475// backoff until either the error returned is not retryable() or the context
476// expires.
477func clientDoWithRetries[T any](ctx context.Context,
478 getClient func() (proto.DRPCProvisionerDaemonClient, bool),
479 f func(context.Context, proto.DRPCProvisionerDaemonClient) (T, error),
480) (ret T, _ error) {
481 for retrier := retry.New(25*time.Millisecond, 5*time.Second); retrier.Wait(ctx); {
482 client, ok := getClient()
483 if !ok {
484 continue
485 }
486 resp, err := f(ctx, client)
487 if retryable(err) {
488 continue
489 }
490 return resp, err
491 }
492 return ret, ctx.Err()
493}
494
495func (p *Server) CommitQuota(ctx context.Context, in *proto.CommitQuotaRequest) (*proto.CommitQuotaResponse, error) {
496 out, err := clientDoWithRetries(ctx, p.client, func(ctx context.Context, client proto.DRPCProvisionerDaemonClient) (*proto.CommitQuotaResponse, error) {

Callers 6

CommitQuotaMethod · 0.85
UpdateJobMethod · 0.85
FailJobMethod · 0.85
UploadModuleFilesMethod · 0.85
DownloadFileMethod · 0.85
CompleteJobMethod · 0.85

Calls 4

retryableFunction · 0.85
ErrMethod · 0.80
NewMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected