Documentation ¶
Index ¶
- Constants
- Variables
- func WrapHTTPClient(client *http.Client, headers map[string]string, rps int) *http.Client
- type ClientOption
- type ClusterIdentity
- type Endpoint
- type EndpointProvider
- type EndpointProviderParams
- type EndpointProviderResult
- type FailoverManager
- type FailoverManagerParams
- type RosettaEndpointProvider
- type RosettaEndpointsParams
- type RosettaEndpointsResult
Constants ¶
View Source
const (
MasterSlaveClusters = MasterCluster | SlaveCluster
)
Variables ¶
View Source
var (
)
View Source
var Module = fx.Options( fx.Provide(NewEndpointProvider), fx.Provide(NewRosettaEndpointProvider), fx.Provide(NewFailoverManager), )
Functions ¶
Types ¶
type ClientOption ¶
type ClientOption func(opts *clientOptions)
type ClusterIdentity ¶
type ClusterIdentity int
const ( MasterCluster ClusterIdentity = 1 << iota SlaveCluster ValidatorCluster ConsensusCluster )
type Endpoint ¶
type Endpoint struct { Name string Config *config.Endpoint Client *http.Client // contains filtered or unexported fields }
func (*Endpoint) IncRequestsCounter ¶
type EndpointProvider ¶
type EndpointProvider interface { GetEndpoint(ctx context.Context) (*Endpoint, error) GetAllEndpoints() []*Endpoint GetActiveEndpoints(ctx context.Context) []*Endpoint WithFailoverContext(ctx context.Context) (context.Context, error) HasFailoverContext(ctx context.Context) bool }
EndpointProvider encapsulates the client-side routing logic. By default, the request is routed to one of the primary endpoints based on their weights. When the failover context is seen, the request is instead routed to one of the secondary endpoints. In most cases, the primary endpoints are referring to the `EndpointGroup.Endpoints` config, while the secondary endpoints are referring to the `EndpointGroup.EndpointsFailover` config. But when `EndpointGroup.UseFailover` is turned on, the two list are swapped.
type EndpointProviderParams ¶
type EndpointProviderResult ¶
type EndpointProviderResult struct { fx.Out Master EndpointProvider `name:"master"` Slave EndpointProvider `name:"slave"` Validator EndpointProvider `name:"validator"` Consensus EndpointProvider `name:"consensus"` }
func NewEndpointProvider ¶
func NewEndpointProvider(params EndpointProviderParams) (EndpointProviderResult, error)
type FailoverManager ¶
type FailoverManager interface {
WithFailoverContext(ctx context.Context, cluster ClusterIdentity) (context.Context, error)
}
func NewFailoverManager ¶
func NewFailoverManager(params FailoverManagerParams) FailoverManager
type FailoverManagerParams ¶
type FailoverManagerParams struct { fx.In Master EndpointProvider `name:"master"` Slave EndpointProvider `name:"slave"` Validator EndpointProvider `name:"validator"` Consensus EndpointProvider `name:"consensus"` }
type RosettaEndpointProvider ¶
type RosettaEndpointsParams ¶
type RosettaEndpointsParams struct { fx.In Master EndpointProvider `name:"master"` Slave EndpointProvider `name:"slave"` Validator EndpointProvider `name:"validator"` Consensus EndpointProvider `name:"consensus"` }
type RosettaEndpointsResult ¶
type RosettaEndpointsResult struct { fx.Out Master RosettaEndpointProvider `name:"master"` Slave RosettaEndpointProvider `name:"slave"` Validator RosettaEndpointProvider `name:"validator"` Consensus RosettaEndpointProvider `name:"consensus"` }
func NewRosettaEndpointProvider ¶
func NewRosettaEndpointProvider(params RosettaEndpointsParams) (RosettaEndpointsResult, error)
Click to show internal directories.
Click to hide internal directories.