Skip to content

Commit

Permalink
rework retry close
Browse files Browse the repository at this point in the history
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
  • Loading branch information
denis-tingaikin committed Dec 14, 2023
1 parent 337314d commit 0525d62
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions pkg/networkservice/common/retry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,5 @@ func (r *retryClient) Request(ctx context.Context, request *networkservice.Netwo
}

func (r *retryClient) Close(ctx context.Context, conn *networkservice.Connection, opts ...grpc.CallOption) (*emptypb.Empty, error) {
logger := log.FromContext(ctx).WithField("retryClient", "Close")
c := clock.FromContext(ctx)

for ctx.Err() == nil {
closeCtx, cancel := c.WithTimeout(ctx, r.tryTimeout)

resp, err := next.Client(ctx).Close(closeCtx, conn.Clone(), opts...)
cancel()

if err != nil {
logger.Errorf("try attempt has failed: %v", err.Error())

select {
case <-ctx.Done():
return nil, ctx.Err()
case <-c.After(r.interval):
continue
}
}

return resp, err
}

return nil, ctx.Err()
return next.Client(ctx).Close(ctx, conn.Clone(), opts...)
}

0 comments on commit 0525d62

Please sign in to comment.