grpcserver

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCreateListener is returned when the listener creation fails.
	ErrCreateListener = errors.New("failed to create listener")

	// ErrServerNotStarted is returned when the server is not started yet.
	ErrServerNotStarted = errors.New("server not started")
)

Functions

This section is empty.

Types

type Option

type Option func(*server)

Option is a function that configures the gRPC server.

func WithDefaultInterceptors

func WithDefaultInterceptors() Option

WithDefaultInterceptors adds the default interceptors to the gRPC server.

func WithPort

func WithPort(port int) Option

WithPort sets the port for the gRPC server.

func WithStreamInterceptor

func WithStreamInterceptor(i grpc.StreamServerInterceptor) Option

WithStreamInterceptor adds a stream interceptor to the gRPC server.

func WithUnaryInterceptor

func WithUnaryInterceptor(i grpc.UnaryServerInterceptor) Option

WithUnaryInterceptor adds a unary interceptor to the gRPC server.

type Server

type Server interface {
	// RegisterService registers a service to the gRPC server.
	RegisterService(registration ServiceRegistration)

	// Start starts the gRPC server.
	Start(context.Context) error

	// Stop stops the gRPC server.
	Stop(context.Context) error
}

Server is a gRPC server.

func NewServer

func NewServer(appName string, opts ...Option) Server

NewServer creates a new gRPC server.

type ServiceRegistration

type ServiceRegistration func(grpc.ServiceRegistrar)

ServiceRegistration is a function that registers a service to the gRPC server.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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