Documentation ¶
Index ¶
- Variables
- type CoreClient
- type ErrorCode
- type InsecureGRPCClient
- func (c *InsecureGRPCClient) CheckTransaction(ctx context.Context, req *apipb.CheckTransactionRequest, ...) (*apipb.CheckTransactionResponse, error)
- func (c *InsecureGRPCClient) GetVegaTime(ctx context.Context, req *apipb.GetVegaTimeRequest, opts ...grpc.CallOption) (*apipb.GetVegaTimeResponse, error)
- func (c *InsecureGRPCClient) Host() string
- func (c *InsecureGRPCClient) LastBlockHeight(ctx context.Context, req *apipb.LastBlockHeightRequest, ...) (*apipb.LastBlockHeightResponse, error)
- func (c *InsecureGRPCClient) Stop() error
- func (c *InsecureGRPCClient) SubmitTransaction(ctx context.Context, req *apipb.SubmitTransactionRequest, ...) (*apipb.SubmitTransactionResponse, error)
- type Node
- type ReportType
- type RetryingGRPCNode
- func (n *RetryingGRPCNode) CheckTransaction(ctx context.Context, tx *commandspb.Transaction) (*apipb.CheckTransactionResponse, error)
- func (n *RetryingGRPCNode) HealthCheck(ctx context.Context) error
- func (n *RetryingGRPCNode) Host() string
- func (n *RetryingGRPCNode) LastBlock(ctx context.Context) (*apipb.LastBlockHeightResponse, error)
- func (n *RetryingGRPCNode) SendTransaction(ctx context.Context, tx *commandspb.Transaction, ...) (string, error)
- func (n *RetryingGRPCNode) Stop() error
- type RoundRobinSelector
- type SelectionReporter
- type Selector
- type StatusError
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoNodeConfigured = errors.New("no node configured on round-robin selector") ErrNoHealthyNodeAvailable = errors.New("no healthy node available") )
Functions ¶
This section is empty.
Types ¶
type CoreClient ¶
type CoreClient interface { Host() string SubmitTransaction(ctx context.Context, in *apipb.SubmitTransactionRequest, opts ...grpc.CallOption) (*apipb.SubmitTransactionResponse, error) LastBlockHeight(ctx context.Context, in *apipb.LastBlockHeightRequest, opts ...grpc.CallOption) (*apipb.LastBlockHeightResponse, error) GetVegaTime(ctx context.Context, in *apipb.GetVegaTimeRequest, opts ...grpc.CallOption) (*apipb.GetVegaTimeResponse, error) CheckTransaction(ctx context.Context, in *apipb.CheckTransactionRequest, opts ...grpc.CallOption) (*apipb.CheckTransactionResponse, error) Stop() error }
type InsecureGRPCClient ¶
type InsecureGRPCClient struct {
// contains filtered or unexported fields
}
func NewInsecureGRPCClient ¶
func NewInsecureGRPCClient(host string) (*InsecureGRPCClient, error)
func (*InsecureGRPCClient) CheckTransaction ¶
func (c *InsecureGRPCClient) CheckTransaction(ctx context.Context, req *apipb.CheckTransactionRequest, opts ...grpc.CallOption) (*apipb.CheckTransactionResponse, error)
func (*InsecureGRPCClient) GetVegaTime ¶
func (c *InsecureGRPCClient) GetVegaTime(ctx context.Context, req *apipb.GetVegaTimeRequest, opts ...grpc.CallOption) (*apipb.GetVegaTimeResponse, error)
func (*InsecureGRPCClient) Host ¶
func (c *InsecureGRPCClient) Host() string
func (*InsecureGRPCClient) LastBlockHeight ¶
func (c *InsecureGRPCClient) LastBlockHeight(ctx context.Context, req *apipb.LastBlockHeightRequest, opts ...grpc.CallOption) (*apipb.LastBlockHeightResponse, error)
func (*InsecureGRPCClient) Stop ¶
func (c *InsecureGRPCClient) Stop() error
func (*InsecureGRPCClient) SubmitTransaction ¶
func (c *InsecureGRPCClient) SubmitTransaction(ctx context.Context, req *apipb.SubmitTransactionRequest, opts ...grpc.CallOption) (*apipb.SubmitTransactionResponse, error)
type Node ¶ added in v0.56.0
type Node interface { Host() string Stop() error SendTransaction(context.Context, *commandspb.Transaction, apipb.SubmitTransactionRequest_Type) (string, error) CheckTransaction(context.Context, *commandspb.Transaction) (*apipb.CheckTransactionResponse, error) HealthCheck(context.Context) error LastBlock(context.Context) (*apipb.LastBlockHeightResponse, error) }
Node is the component used to get network information and send transactions.
type ReportType ¶ added in v0.56.0
type ReportType string
ReportType defines the type of event that occurred.
var ( InfoEvent ReportType = "Info" WarningEvent ReportType = "Warning" ErrorEvent ReportType = "Error" SuccessEvent ReportType = "Success" )
type RetryingGRPCNode ¶
type RetryingGRPCNode struct {
// contains filtered or unexported fields
}
func BuildRetryingGRPCNode ¶ added in v0.56.0
func BuildRetryingGRPCNode(log *zap.Logger, client CoreClient, retries uint64) *RetryingGRPCNode
func NewRetryingGRPCNode ¶ added in v0.56.0
func (*RetryingGRPCNode) CheckTransaction ¶
func (n *RetryingGRPCNode) CheckTransaction(ctx context.Context, tx *commandspb.Transaction) (*apipb.CheckTransactionResponse, error)
func (*RetryingGRPCNode) HealthCheck ¶
func (n *RetryingGRPCNode) HealthCheck(ctx context.Context) error
HealthCheck returns an error if the node is not healthy. Contrary to the other calls, it doesn't retry if the call ends up in error to avoid useless delay in during node selection.
func (*RetryingGRPCNode) Host ¶
func (n *RetryingGRPCNode) Host() string
func (*RetryingGRPCNode) LastBlock ¶
func (n *RetryingGRPCNode) LastBlock(ctx context.Context) (*apipb.LastBlockHeightResponse, error)
LastBlock returns information about the last block acknowledged by the node.
func (*RetryingGRPCNode) SendTransaction ¶
func (n *RetryingGRPCNode) SendTransaction(ctx context.Context, tx *commandspb.Transaction, ty apipb.SubmitTransactionRequest_Type) (string, error)
func (*RetryingGRPCNode) Stop ¶
func (n *RetryingGRPCNode) Stop() error
type RoundRobinSelector ¶
type RoundRobinSelector struct {
// contains filtered or unexported fields
}
RoundRobinSelector uses a classic round-robin algorithm to select a node. When requesting the next node, this is the node right behind the current one that is selected. When the last node is reached, it starts over the first one.
func NewRoundRobinSelector ¶
func NewRoundRobinSelector(log *zap.Logger, nodes ...Node) (*RoundRobinSelector, error)
func (*RoundRobinSelector) Node ¶
func (ns *RoundRobinSelector) Node(ctx context.Context, reporterFn SelectionReporter) (Node, error)
func (*RoundRobinSelector) Stop ¶
func (ns *RoundRobinSelector) Stop()
Stop stops all the registered nodes. If a node raises an error during closing, the selector ignores it and carry on a best-effort.
type SelectionReporter ¶ added in v0.56.0
type SelectionReporter func(ReportType, string)
type Selector ¶ added in v0.56.0
type Selector interface { Node(ctx context.Context, reporterFn SelectionReporter) (Node, error) Stop() }
Selector implementing the strategy for node selection.
type StatusError ¶
func (*StatusError) Error ¶
func (e *StatusError) Error() string