Class: KubeMQ::Interceptors::RetryInterceptor Private
- Inherits:
-
GRPC::ClientInterceptor
- Object
- GRPC::ClientInterceptor
- KubeMQ::Interceptors::RetryInterceptor
- Defined in:
- lib/kubemq/interceptors/retry_interceptor.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
gRPC client interceptor that retries failed unary RPCs with exponential backoff.
Only unary (+request_response+) calls are retried; streaming RPCs pass through unchanged because retrying a partial stream is not safe.
Retryable gRPC status codes: UNAVAILABLE, ABORTED, DEADLINE_EXCEEDED.
Constant Summary collapse
- RETRYABLE_CODES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
gRPC status codes eligible for automatic retry.
[ GRPC::Core::StatusCodes::UNAVAILABLE, GRPC::Core::StatusCodes::ABORTED, GRPC::Core::StatusCodes::DEADLINE_EXCEEDED ].freeze
- DEFAULT_MAX_RETRIES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Maximum number of retry attempts for unary RPCs.
3- DEFAULT_BASE_DELAY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Initial backoff delay in seconds.
0.1- DEFAULT_MULTIPLIER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Multiplier applied to delay after each retry attempt.
2.0
Instance Method Summary collapse
-
#bidi_streamer(requests:, call:, method:, metadata:, &block) ⇒ Enumerator
private
Passes bidirectional-streaming RPCs through without retry.
-
#client_streamer(requests:, call:, method:, metadata:, &block) ⇒ Object
private
Passes client-streaming RPCs through without retry.
-
#initialize(max_retries: DEFAULT_MAX_RETRIES, base_delay: DEFAULT_BASE_DELAY, multiplier: DEFAULT_MULTIPLIER) ⇒ RetryInterceptor
constructor
private
A new instance of RetryInterceptor.
-
#request_response(request:, call:, method:, metadata:, &block) ⇒ Object
private
Executes a unary RPC with automatic retry on transient failures.
-
#server_streamer(request:, call:, method:, metadata:, &block) ⇒ Enumerator
private
Passes server-streaming RPCs through without retry.
Constructor Details
#initialize(max_retries: DEFAULT_MAX_RETRIES, base_delay: DEFAULT_BASE_DELAY, multiplier: DEFAULT_MULTIPLIER) ⇒ RetryInterceptor
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RetryInterceptor.
38 39 40 41 42 43 44 |
# File 'lib/kubemq/interceptors/retry_interceptor.rb', line 38 def initialize(max_retries: DEFAULT_MAX_RETRIES, base_delay: DEFAULT_BASE_DELAY, multiplier: DEFAULT_MULTIPLIER) super() @max_retries = max_retries @base_delay = base_delay @multiplier = multiplier end |
Instance Method Details
#bidi_streamer(requests:, call:, method:, metadata:, &block) ⇒ Enumerator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Passes bidirectional-streaming RPCs through without retry.
87 88 89 |
# File 'lib/kubemq/interceptors/retry_interceptor.rb', line 87 def bidi_streamer(requests:, call:, method:, metadata:, &block) block.call(requests, call, method, ) end |
#client_streamer(requests:, call:, method:, metadata:, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Passes client-streaming RPCs through without retry.
76 77 78 |
# File 'lib/kubemq/interceptors/retry_interceptor.rb', line 76 def client_streamer(requests:, call:, method:, metadata:, &block) block.call(requests, call, method, ) end |
#request_response(request:, call:, method:, metadata:, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Executes a unary RPC with automatic retry on transient failures.
54 55 56 |
# File 'lib/kubemq/interceptors/retry_interceptor.rb', line 54 def request_response(request:, call:, method:, metadata:, &block) with_retry { block.call(request, call, method, ) } end |
#server_streamer(request:, call:, method:, metadata:, &block) ⇒ Enumerator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Passes server-streaming RPCs through without retry.
65 66 67 |
# File 'lib/kubemq/interceptors/retry_interceptor.rb', line 65 def server_streamer(request:, call:, method:, metadata:, &block) block.call(request, call, method, ) end |