grpclib

package
v0.0.0-...-db5373c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClient

func CreateClient[T any](new func(grpc.ClientConnInterface) T, opts ClientOptions) (res T, err error)

func InternalError

func InternalError(msg string, err error, args ...interface{}) error

func InvalidArgument

func InvalidArgument(msg string, args ...interface{}) error

func NotFound

func NotFound(msg string, args ...interface{}) error

Types

type ClientOptions

type ClientOptions struct {
	Url         string `validate:"required,url"`
	Logger      *slog.Logger
	Credentials *certlib.ClientTLSConfigFiles
	ServerName  string // Added for TLS verification
}

type EnvServerConfig

type EnvServerConfig struct {
	Port     int    `env:"GRPC_PORT" validate:"required,numeric"`
	CertFile string `env:"GRPC_CERT" validate:"omitempty,filepath"`
	KeyFile  string `env:"GRPC_KEY" validate:"omitempty,filepath"`
	CAFile   string `env:"GRPC_CA" validate:"omitempty,filepath"`
}

type GrpcServer

type GrpcServer struct {
	// contains filtered or unexported fields
}

func NewGrpcServer

func NewGrpcServer(opts ServerOptions) (*GrpcServer, error)

func (*GrpcServer) Start

func (gs *GrpcServer) Start() error

func (*GrpcServer) Stop

func (gs *GrpcServer) Stop()

type ServerOptions

type ServerOptions struct {
	Port        int               `validate:"required,number"`
	ServiceDesc *grpc.ServiceDesc `validate:"required"`
	Handler     interface{}       `validate:"required"`
	Logger      *slog.Logger
	TLSConfig   *certlib.ServerTLSConfigFiles `validate:"omitempty"`
}

func ServerOptionsFromEnvConfig

func ServerOptionsFromEnvConfig(cfg EnvServerConfig) ServerOptions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL