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), )
| 475 | // backoff until either the error returned is not retryable() or the context |
| 476 | // expires. |
| 477 | func 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 | |
| 495 | func (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) { |
no test coverage detected