Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrGRPCConnectionNotReady = errors.New("gRPC connection is not ready")
ErrGRPCConnectionNotReady is returned when the gRPC connection is not in a ready state.
Functions ¶
Types ¶
type GRPCConnection ¶
type GRPCConnection struct {
Addr string
Conn *grpc.ClientConn
Logger libLog.Logger
}
GRPCConnection is a struct which deal with gRPC connections.
func (*GRPCConnection) CheckHealth ¶ added in v3.4.8
func (c *GRPCConnection) CheckHealth(ctx context.Context) error
CheckHealth verifies that the gRPC connection is healthy and ready to accept requests. It loops through gRPC connectivity state transitions (Idle → Connecting → Ready) within a configurable timeout from GRPC_HEALTH_CHECK_TIMEOUT environment variable (default: 5 seconds).
func (*GRPCConnection) Connect ¶
func (c *GRPCConnection) Connect() error
Connect keeps a singleton connection with gRPC.
func (*GRPCConnection) ContextMetadataInjection ¶
func (c *GRPCConnection) ContextMetadataInjection(ctx context.Context, token string) context.Context
ContextMetadataInjection injects OpenTelemetry trace context and optional authorization into the outgoing gRPC context. It preserves existing metadata and appends: - traceparent/tracestate (W3C propagated via OpenTelemetry) - authorization (JWT), when provided
func (*GRPCConnection) GetNewClient ¶
func (c *GRPCConnection) GetNewClient() (*grpc.ClientConn, error)
GetNewClient returns a connection to gRPC, reconnect it if necessary.