Grpc Go-API
import "givc/modules/pkgs/grpc"
The grpc package provides functionality to create and manage gRPC server and client connections.
Copyright 2024 TII (SSRC) and the Ghaf contributors SPDX-License-Identifier: Apache-2.0
- Constants
- func NewClient(cfg *types.EndpointConfig) (*grpc.ClientConn, error)
- func unaryLogRequestInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
- func vsockDialer(ctx context.Context, addr string) (net.Conn, error)
- func withOutgoingContext(ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts …grpc.CallOption) error
- func withRetryOpts() grpc.UnaryClientInterceptor
- type GrpcServer
- type GrpcServerConfig
Constants
Section titled “Constants”Constants for gRPC client configuration
const ( MAX_RETRY = uint(3) TIMEOUT = 150 * time.Millisecond)
Constants for gRPC server configuration
const ( LISTENER_WAIT_TIME = 1 * time.Second LISTENER_RETRIES = 20)
func NewClient
Section titled “func NewClient”func NewClient(cfg *types.EndpointConfig) (*grpc.ClientConn, error)
NewClient creates a new gRPC client connection based on the provided endpoint configuration.
func unaryLogRequestInterceptor
Section titled “func unaryLogRequestInterceptor”func unaryLogRequestInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
func vsockDialer
Section titled “func vsockDialer”func vsockDialer(ctx context.Context, addr string) (net.Conn, error)
vsockDialer is a custom dialer for vsock connections.
func withOutgoingContext
Section titled “func withOutgoingContext”func withOutgoingContext(ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
withOutgoingContext is a gRPC client interceptor that adds outgoing metadata to the context.
func withRetryOpts
Section titled “func withRetryOpts”func withRetryOpts() grpc.UnaryClientInterceptor
withRetryOpts is a gRPC client interceptor that adds retry options to the gRPC call.
type GrpcServer
Section titled “type GrpcServer”type GrpcServer struct { config *GrpcServerConfig grpcServer *grpc.Server}
func NewServer
Section titled “func NewServer”func NewServer(cfg *types.EndpointConfig, services []types.GrpcServiceRegistration) (*GrpcServer, error)
NewServer creates a new gRPC server based on the provided endpoint configuration and service registrations.
func (*GrpcServer) ListenAndServe
Section titled “func (*GrpcServer) ListenAndServe”func (s *GrpcServer) ListenAndServe(ctx context.Context, started chan struct{}) error
ListenAndServe starts the gRPC server and listens for incoming connections.
type GrpcServerConfig
Section titled “type GrpcServerConfig”type GrpcServerConfig struct { Transport *types.TransportConfig TlsConfig *tls.Config Services []types.GrpcServiceRegistration}
Generated by gomarkdoc