grpc

package module
v0.0.0-...-c1cb7b8 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetServerOptions

func GetServerOptions(cfg tls.PathConfig) ([]grpc.ServerOption, error)

GetServerOptions returns the options to be used by the gRPC server.

func ServerErrorHandler

func ServerErrorHandler(err error) error

ServerErrorHandler handles status.Error to gRPC status.Error.

func UnaryInterceptor

func UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

UnaryInterceptor is called as a wrapper between the request and the handler.

Types

type Connection

type Connection[T any] struct {
	// Service client implementation.
	Service T
	// contains filtered or unexported fields
}

Connection implements the connection and closure methods and stores the service implementation.

func Connect

func Connect[T any](fc func(grpc.ClientConnInterface) T, cfg ConnectionConfig) *Connection[T]

Connect creates a new connection to the gRPC service using the service constructor and configuration.

func (*Connection[T]) Close

func (c *Connection[T]) Close()

Close closes the gRPC connection to the service.

type ConnectionConfig

type ConnectionConfig struct {
	// Addr specifies the URL to which the connection will be created.
	Addr string

	// TLS setup configuration for creating TLS config.
	TLS tls.PathConfig
}

ConnectionConfig stores the configurations needed to create a new connection to the gRPC service.

type Handler

type Handler interface {
	// Register is intended for registration of gRPC server handlers.
	Register(srv *grpc.Server)
}

Handler is used in gRPC server.

type Server

type Server struct {
	// Server is an internal grpc.Server structure.
	Server *grpc.Server
	// contains filtered or unexported fields
}

Server that implements the run method.

func NewServer

func NewServer(cfg ServerConfig, handler Handler) *Server

NewServer returns the new gRPC server.

func (*Server) Run

func (s *Server) Run()

Run starts the gRPC server.

type ServerConfig

type ServerConfig struct {
	// Host indicates on which host the server will be started.
	Host string

	// Port indicates on which port the server will be started.
	Port string

	// TLS setup configuration for creating TLS config.
	TLS tls.PathConfig
}

ServerConfig stores the configurations needed to run the gRPC server.

Jump to

Keyboard shortcuts

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