Documentation
¶
Overview ¶
Code generated by hack/gen-logs.sh; DO NOT EDIT. This file is created and regenerated automatically. Anything added here might get removed.
Index ¶
- Constants
- func AppendHeaders(parent context.Context, headers []string) context.Context
- func LogRequests(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, ...) error
- func LogStream(ctx context.Context, sd *grpc.StreamDesc, conn *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func WithPrefix(value string) string
- type GrpcConnectionProvider
- type MockGrpcProvider
Constants ¶
const CustomErrorMetadataKey = "Custom-Error"
CustomErrorMetadataKey is the name of the metadata key storing additional error information. Metadata value is expected to be a byte-encoded JSON object.
const HttpCodeMetadataKey = "X-Http-Code"
HttpCodeMetadataKey is the key to use when setting custom HTTP status codes in gRPC metadata.
const MetadataPrefix = "Grpc-Metadata"
MetadataPrefix is the prefix for grpc headers on metadata
Variables ¶
This section is empty.
Functions ¶
func AppendHeaders ¶
AppendHeaders parses the provided GRPC headers and attaches them to the provided context.
func LogRequests ¶
func LogRequests( ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, ) error
LogRequests logs the gRPC backend as well as request duration when the log level is set to debug or higher.
func LogStream ¶
func LogStream( ctx context.Context, sd *grpc.StreamDesc, conn *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption, ) (grpc.ClientStream, error)
LogStream prints the method at DEBUG level at the start of the stream.
func WithPrefix ¶
WithPrefix creates a new string with grpc metadata prefix
Types ¶
type GrpcConnectionProvider ¶ added in v7.1.3
type GrpcConnectionProvider interface {
// CurrentConn returns the currently active gRPC connection.
// The connection is created lazily on first call.
// Returns nil if the provider has been closed.
CurrentConn() *grpc.ClientConn
// CurrentHost returns the address of the currently active endpoint.
CurrentHost() string
// Hosts returns all configured endpoint addresses.
Hosts() []string
// SwitchHost switches to the endpoint at the given index.
// The new connection is created lazily on next CurrentConn() call.
SwitchHost(index int) error
// ConnectionCounter returns a monotonically increasing counter that increments
// each time SwitchHost changes the active endpoint. This allows consumers to
// detect connection changes even when the host string returns to a previous value
// (e.g., host0 → host1 → host0).
ConnectionCounter() uint64
// Close closes the current connection.
Close()
}
GrpcConnectionProvider manages gRPC connections for failover support. It allows switching between different beacon node endpoints when the current one becomes unavailable. Only one connection is maintained at a time - when switching hosts, the old connection is closed.
func NewGrpcConnectionProvider ¶ added in v7.1.3
func NewGrpcConnectionProvider( ctx context.Context, endpoint string, dialOpts []grpc.DialOption, ) (GrpcConnectionProvider, error)
NewGrpcConnectionProvider creates a new connection provider that manages gRPC connections. The endpoint parameter can be a comma-separated list of addresses (e.g., "host1:4000,host2:4000"). Only one connection is maintained at a time, created lazily on first use.
type MockGrpcProvider ¶ added in v7.1.3
type MockGrpcProvider struct {
MockConn *grpc.ClientConn
MockHosts []string
CurrentIndex int
ConnCounter uint64
}
MockGrpcProvider implements GrpcConnectionProvider for testing.
func (*MockGrpcProvider) Close ¶ added in v7.1.3
func (m *MockGrpcProvider) Close()
func (*MockGrpcProvider) ConnectionCounter ¶ added in v7.1.3
func (m *MockGrpcProvider) ConnectionCounter() uint64
func (*MockGrpcProvider) CurrentConn ¶ added in v7.1.3
func (m *MockGrpcProvider) CurrentConn() *grpc.ClientConn
func (*MockGrpcProvider) CurrentHost ¶ added in v7.1.3
func (m *MockGrpcProvider) CurrentHost() string
func (*MockGrpcProvider) Hosts ¶ added in v7.1.3
func (m *MockGrpcProvider) Hosts() []string
func (*MockGrpcProvider) SwitchHost ¶ added in v7.1.3
func (m *MockGrpcProvider) SwitchHost(idx int) error