import "github.com/blueprint-uservices/blueprint/plugins/retries"
Package retries provides a Blueprint modifier for the client side of service calls.
The plugin wraps clients with a retrier using that retries a request until one of the two conditions is met: i) the requests returns without an error ii) the number of failed tries has reached the maximum number of failures. Usage:
import "github.com/blueprint-uservices/blueprint/plugins/retries"
retries.AddRetries(spec, "my_service", 10) // Only adds retries
retries.AddRetriesWithTimeouts(spec, "my_service", 10, "1s") // Adds retries and timeouts
- func AddRetries(spec wiring.WiringSpec, serviceName string, max_retries int64)
- func AddRetriesWithTimeouts(spec wiring.WiringSpec, serviceName string, max_retries int64, timeout string)
- type RetrierClient
- func (node *RetrierClient) AddInstantiation(builder golang.NamespaceBuilder) error
- func (node *RetrierClient) AddInterfaces(builder golang.ModuleBuilder) error
- func (node *RetrierClient) GenerateFuncs(builder golang.ModuleBuilder) error
- func (node *RetrierClient) GetInterface(ctx ir.BuildContext) (service.ServiceInterface, error)
- func (node *RetrierClient) ImplementsGolangNode()
- func (node *RetrierClient) Name() string
- func (node *RetrierClient) String() string
func AddRetries
func AddRetries(spec wiring.WiringSpec, serviceName string, max_retries int64)
Add retrier functionality to all clients of the specified service. Uses a [blueprint.WiringSpec] Modifies the given service such that all clients to that service retry `max_retries` number of times on error. Usage:
AddRetries(spec, "my_service", 10)
func AddRetriesWithTimeouts(spec wiring.WiringSpec, serviceName string, max_retries int64, timeout string)
Add retrier + timeout functionality to all clients of the specified service. Uses a [blueprint.WiringSpec] Modifies the given service in the following ways: (i) all clients to that service have a user-specified `timeout` for each request. (ii) all clients to that service retry at most `max_retries` number of times on error.
Ordering of functionality depicted via example call-chain: Before:
workflow -> plugin grpc
After:
workflow -> retrier -> timeout -> plugin grpc
Usage:
AddRetriesWithTimeouts(spec, "my_service", 10, "1s")
type RetrierClient
Blueprint IR node representing a Retrier
type RetrierClient struct {
golang.Service
golang.GeneratesFuncs
golang.Instantiable
InstanceName string
Wrapped golang.Service
Max int64
// contains filtered or unexported fields
}
func (*RetrierClient) AddInstantiation
func (node *RetrierClient) AddInstantiation(builder golang.NamespaceBuilder) error
func (*RetrierClient) AddInterfaces
func (node *RetrierClient) AddInterfaces(builder golang.ModuleBuilder) error
func (*RetrierClient) GenerateFuncs
func (node *RetrierClient) GenerateFuncs(builder golang.ModuleBuilder) error
func (*RetrierClient) GetInterface
func (node *RetrierClient) GetInterface(ctx ir.BuildContext) (service.ServiceInterface, error)
func (*RetrierClient) ImplementsGolangNode
func (node *RetrierClient) ImplementsGolangNode()
func (*RetrierClient) Name
func (node *RetrierClient) Name() string
func (*RetrierClient) String
func (node *RetrierClient) String() string
Generated by gomarkdoc