Documentation ¶
Overview ¶
* User: cr-mao Date: 2023/8/17 14:27 Email: crmao@qq.com Desc: server.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrConnShutdown = errors.New("grpc conn shutdown")
Functions ¶
func UnaryCrashInterceptor ¶
func UnaryCrashInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)
防止panic crash 中间件
Types ¶
type ClientBuilder ¶
type ClientBuilder struct {
// contains filtered or unexported fields
}
func NewClientBuilder ¶
func NewClientBuilder(opts *ClientOptions) *ClientBuilder
func (*ClientBuilder) GetConn ¶
func (b *ClientBuilder) GetConn(target string) (*grpc.ClientConn, error)
Build 构建连接
type ClientOptions ¶
type ClientOptions struct { PoolSize int DialOpts []grpc.DialOption }
type Server ¶
Server is a gRPC server wrapper.
func NewServer ¶
func NewServer(addr string, opts ...ServerOption) (*Server, error)
NewServer creates a gRPC server by options.
type ServerOption ¶
type ServerOption func(o *Server)
ServerOption is gRPC server option.
func WithGrpcOpts ¶
func WithGrpcOpts(opts ...grpc.ServerOption) ServerOption
WithGrpcOpts with grpc options.
func WithUnaryInterceptor ¶
func WithUnaryInterceptor(in ...grpc.UnaryServerInterceptor) ServerOption
WithUnaryInterceptor returns a ServerOption that sets the UnaryServerInterceptor for the server.
Click to show internal directories.
Click to hide internal directories.