Documentation ¶
Index ¶
- func GetDefaultClientInterceptor() []grpc.DialOption
- func GetDefaultClientOptions() []grpc.DialOption
- func GetDefaultGRPCRetryPolicy(service string) (grpc.DialOption, error)
- func GetDefaultServerInterceptor() []grpc.ServerOption
- func GetDefaultServerOptions() []grpc.ServerOption
- func GetGRPCErrorCodes() []string
- func SetGRPCRetryPolicy(retryConfig *RetryConfig) (grpc.DialOption, error)
- type MethodConfig
- type Name
- type RetryConfig
- type RetryPolicy
- type RetryThrottling
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultClientInterceptor ¶ added in v0.1.1
func GetDefaultClientInterceptor() []grpc.DialOption
GetDefaultClientInterceptor returns default gRPC client interceptor
func GetDefaultClientOptions ¶
func GetDefaultClientOptions() []grpc.DialOption
GetDefaultClientOptions returns default gRPC client options
func GetDefaultGRPCRetryPolicy ¶ added in v0.1.1
func GetDefaultGRPCRetryPolicy(service string) (grpc.DialOption, error)
GetDefaultGRPCRetryPolicy returns default gRPC retry policy
func GetDefaultServerInterceptor ¶ added in v0.1.1
func GetDefaultServerInterceptor() []grpc.ServerOption
GetDefaultServerInterceptor returns default gRPC server interceptor
func GetDefaultServerOptions ¶
func GetDefaultServerOptions() []grpc.ServerOption
GetDefaultServerOptions returns default gRPC server options
func GetGRPCErrorCodes ¶ added in v0.1.1
func GetGRPCErrorCodes() []string
GetGRPCErrorCodes returns all gRPC error codes
func SetGRPCRetryPolicy ¶ added in v0.1.1
func SetGRPCRetryPolicy(retryConfig *RetryConfig) (grpc.DialOption, error)
SetGRPCRetryPolicy sets gRPC retry policy
Types ¶
type MethodConfig ¶ added in v0.1.1
type MethodConfig struct { Name []Name `json:"name"` // WaitForReady indicates whether RPCs sent to this method should wait until // the connection is ready by default (!failfast). The value specified via the // gRPC client API will override the value set here. WaitForReady bool `json:"waitForReady,omitempty"` // Timeout is the default timeout for RPCs sent to this method. The actual // deadline used will be the minimum of the value specified here and the value // set by the application via the gRPC client API. If either one is not set, // then the other will be used. If neither is set, then the RPC has no deadline. Timeout string `json:"timeout,omitempty"` // MaxRequestMessageBytes is the maximum allowed payload size for an individual request in a // stream (client->server) in bytes. The size which is measured is the serialized // payload after per-message compression (but before stream compression) in bytes. // The actual value used is the minimum of the value specified here and the value set // by the application via the gRPC client API. If either one is not set, then the other // will be used. If neither is set, then the built-in default is used. MaxRequestMessageBytes int `json:"maxRequestMessageBytes,omitempty"` // MaxResponseMessageBytes is the maximum allowed payload size for an individual response in a // stream (server->client) in bytes. MaxResponseMessageBytes int `json:"maxResponseMessageBytes,omitempty"` // RetryPolicy configures retry options for the method. RetryPolicy *RetryPolicy `json:"retryPolicy"` }
type Name ¶ added in v0.1.1
type Name struct { Service string `json:"service"` // Service defines gRPC service name Method string `json:"method,omitempty"` // Method defines gRPC method name }
Name describes a gRPC service
type RetryConfig ¶ added in v0.1.1
type RetryConfig struct {
MethodConfig []*MethodConfig `json:"methodConfig"`
}
RetryConfig defines the retry config of gRPC
An example of gRPC retry config in json format:
`{ "methodConfig": [{ "name": [{"service": "service.uploader.types.UploaderService"}], "waitForReady": true, "retryPolicy": { "maxAttempts": 3, "initialBackoff": ".2s", "maxBackoff": "20s", "backoffMultiplier": 2, "retryableStatusCodes": ["CANCELLED"] }}] }`
type RetryPolicy ¶ added in v0.1.1
type RetryPolicy struct { // MaxAttempts is the maximum number of attempts, including the original RPC. // // This field is required and must be two or greater. MaxAttempts int `json:"maxAttempts"` // Exponential backoff parameters. The initial retry attempt will occur at // random(0, initialBackoff). In general, the nth attempt will occur at // random(0, // min(initialBackoff*backoffMultiplier**(n-1), maxBackoff)). // // These fields are required and must be greater than zero. InitialBackoff string `json:"initialBackoff"` // MaxBackoff sets max backoff MaxBackoff string `json:"maxBackoff"` // BackoffMultiplier sets backoff multiplier BackoffMultiplier float64 `json:"backoffMultiplier"` // The set of status codes which may be retried. // // Status codes are specified as strings, e.g., "UNAVAILABLE". // // This field is required and must be non-empty. // Note: a set is used to store this for easy lookup. RetryableStatusCodes []string `json:"retryableStatusCodes"` }
MaxAttempts is the maximum number of attempts, including the original RPC.
This field is required and must be two or greater.
type RetryThrottling ¶ added in v0.1.1
type RetryThrottling struct { // The number of tokens starts at maxTokens. The token_count will always be // between 0 and maxTokens. // // This field is required and must be in the range (0, 1000]. Up to 3 // decimal places are supported MaxTokens int `json:"maxTokens"` // The amount of tokens to add on each successful RPC. Typically, this will // be some number between 0 and 1, e.g., 0.1. // // This field is required and must be greater than zero. Up to 3 decimal // places are supported. TokenRatio int `json:"tokenRatio"` }
If a RetryThrottling is provided, gRPC will automatically throttle retry attempts and hedged RPCs when the client’s ratio of failures to successes exceeds a threshold.