krpc

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 28 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Ctx    = grpcctx.Ctx  // Ctx manages the context feature.
	Client = krpcClient{} // Client manages the client features.
	Server = krpcServer{} // Server manages the server feature.
)

Functions

This section is empty.

Types

type GrpcServer

type GrpcServer struct {
	Server *grpc.Server
	// contains filtered or unexported fields
}

GrpcServer is the server for GRPC protocol.

func (*GrpcServer) Run

func (s *GrpcServer) Run()

Run starts the server in blocking way.

func (*GrpcServer) Service

func (s *GrpcServer) Service(services ...gsvc.Service)

Service binds service list to current server. Server will automatically register the service list after it starts.

func (*GrpcServer) Start

func (s *GrpcServer) Start()

Start starts the server in no-blocking way.

func (*GrpcServer) Stop

func (s *GrpcServer) Stop()

Stop gracefully stops the server.

func (*GrpcServer) UnaryLogger

func (s *GrpcServer) UnaryLogger(
	ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler,
) (interface{}, error)

UnaryLogger is the default unary interceptor for logging purpose.

func (*GrpcServer) Wait

func (s *GrpcServer) Wait()

Wait works with Start, which blocks current goroutine until the server stops.

type GrpcServerConfig

type GrpcServerConfig struct {
	Address          string              // (optional) Address for server listening.
	Name             string              // (optional) Name for current service.
	Logger           *glog.Logger        // (optional) Logger for server.
	LogPath          string              // (optional) LogPath specifies the directory for storing logging files.
	LogStdout        bool                // (optional) LogStdout specifies whether printing logging content to stdout.
	ErrorStack       bool                // (optional) ErrorStack specifies whether logging stack information when error.
	ErrorLogEnabled  bool                // (optional) ErrorLogEnabled enables error logging content to files.
	ErrorLogPattern  string              // (optional) ErrorLogPattern specifies the error log file pattern like: error-{Ymd}.log
	AccessLogEnabled bool                // (optional) AccessLogEnabled enables access logging content to file.
	AccessLogPattern string              // (optional) AccessLogPattern specifies the error log file pattern like: access-{Ymd}.log
	Options          []grpc.ServerOption // (optional) GRPC Server options.
}

GrpcServerConfig is the configuration for server.

func (*GrpcServerConfig) MustSetWithMap

func (c *GrpcServerConfig) MustSetWithMap(m g.Map)

MustSetWithMap acts as SetWithMap but panics if error occurs.

func (*GrpcServerConfig) SetWithMap

func (c *GrpcServerConfig) SetWithMap(m g.Map) error

SetWithMap changes current configuration with map. This is commonly used for changing several configurations of current object.

type Service added in v0.4.0

type Service struct {
	gsvc.Service
	Endpoints gsvc.Endpoints
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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