server

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRunner

func NewRunner(grpcSrv *grpc.Server, lis net.Listener) *runner

Types

type Config

type Config struct {
	// 服务名称,命名空间内唯一的调用标识
	ServerName string
	// 服务监听的端口
	Port int
}

Config 是gRPC server的配置

type Server

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

Server is the framework's server side instance, it contains the GrpcServer, interceptor and interceptors. Create an instance of Server, by using NewServer().

func NewServer

func NewServer(conf *Config, o ...grpc.ServerOption) (s *Server)

NewServer create a grpc server instance

func (*Server) GrpcServer

func (s *Server) GrpcServer() *grpc.Server

func (*Server) HealthService

func (s *Server) HealthService() *health.Server

func (*Server) Start

func (s *Server) Start() error

Start create a tcp listener and start goroutine for serving each incoming request. Start will block until term signal is received.

func (*Server) Use

func (s *Server) Use(interceptors ...grpc.UnaryServerInterceptor) *Server

Use attachs a global inteceptor to the server. For example, this is the right place for a rate limiter or error management inteceptor. This function is not concurrency safe.

Jump to

Keyboard shortcuts

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