Documentation
¶
Index ¶
- func Dial(ctx context.Context, opts ...GRPCClientOption) (*grpc.ClientConn, error)
- func StreamServerInterceptor(m ...middleware.Middleware) grpc.StreamServerInterceptor
- func TranslateError(err error) error
- func UnaryServerInterceptor(m ...middleware.Middleware) grpc.UnaryServerInterceptor
- type GRPCClientOption
- func WithBalancer(balancer string) GRPCClientOption
- func WithClientInterceptor(interceptors ...grpc.UnaryClientInterceptor) GRPCClientOption
- func WithClientTLS(cert string) GRPCClientOption
- func WithClientTimeout(timeout time.Duration) GRPCClientOption
- func WithDialOption(opts ...grpc.DialOption) GRPCClientOption
- func WithEndpoint(endpoint string) GRPCClientOption
- func WithInsecure() GRPCClientOption
- type GRPCClientOptions
- type GRPCServer
- type GRPCServerOption
- func WithAddress(addr string) GRPCServerOption
- func WithGracefulStop(graceful bool) GRPCServerOption
- func WithGroup(group string) GRPCServerOption
- func WithMiddleware(m ...middleware.Middleware) GRPCServerOption
- func WithName(name string) GRPCServerOption
- func WithTLS(cert, key string) GRPCServerOption
- func WithTimeout(timeout time.Duration) GRPCServerOption
- func WithWeight(weight uint32) GRPCServerOption
- type Server
- type ServerOption
- func Address(address string) ServerOption
- func EidolaServer(server *eidola.Server) ServerOption
- func Logger(logger log.Logger) ServerOption
- func Name(name string) ServerOption
- func Network(network string) ServerOption
- func Options(opts ...grpc.ServerOption) ServerOption
- func TLSConfig(c *tls.Config) ServerOption
- func Timeout(timeout time.Duration) ServerOption
- func WithStreamServerInterceptors(interceptors ...grpc.StreamServerInterceptor) ServerOption
- func WithUnaryServerInterceptors(interceptors ...grpc.UnaryServerInterceptor) ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dial ¶
func Dial(ctx context.Context, opts ...GRPCClientOption) (*grpc.ClientConn, error)
Dial 创建到gRPC服务器的连接
func StreamServerInterceptor ¶
func StreamServerInterceptor(m ...middleware.Middleware) grpc.StreamServerInterceptor
StreamServerInterceptor 创建一个gRPC流拦截器,使用phantasm中间件
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(m ...middleware.Middleware) grpc.UnaryServerInterceptor
UnaryServerInterceptor 创建一个gRPC一元拦截器,使用phantasm中间件
Types ¶
type GRPCClientOption ¶
type GRPCClientOption func(*GRPCClientOptions)
GRPCClientOption 是gRPC客户端选项
func WithClientInterceptor ¶
func WithClientInterceptor(interceptors ...grpc.UnaryClientInterceptor) GRPCClientOption
WithClientInterceptor 添加客户端拦截器
func WithClientTimeout ¶
func WithClientTimeout(timeout time.Duration) GRPCClientOption
WithClientTimeout 设置客户端超时
func WithDialOption ¶
func WithDialOption(opts ...grpc.DialOption) GRPCClientOption
WithDialOption 添加拨号选项
type GRPCClientOptions ¶
type GRPCClientOptions struct {
Endpoint string
Timeout time.Duration
TLSCert string
Insecure bool
Balancer string
DialOptions []grpc.DialOption
Interceptors []grpc.UnaryClientInterceptor
}
GRPCClientOptions 是gRPC客户端选项集合
type GRPCServer ¶
type GRPCServer struct {
// contains filtered or unexported fields
}
GRPCServer 是gRPC服务器
func NewGRPCServer ¶
func NewGRPCServer(opts ...GRPCServerOption) (*GRPCServer, error)
NewGRPCServer 创建一个新的gRPC服务器
func (*GRPCServer) Endpoint ¶
func (s *GRPCServer) Endpoint() (*url.URL, error)
Endpoint 返回gRPC服务器的URL端点
func (*GRPCServer) RegisterService ¶
func (s *GRPCServer) RegisterService(desc *grpc.ServiceDesc, impl interface{})
RegisterService 注册gRPC服务
type GRPCServerOption ¶
type GRPCServerOption func(*GRPCServer)
GRPCServerOption 是gRPC服务器选项
func WithGracefulStop ¶
func WithGracefulStop(graceful bool) GRPCServerOption
WithGracefulStop 设置是否优雅停止
func WithMiddleware ¶
func WithMiddleware(m ...middleware.Middleware) GRPCServerOption
WithMiddleware 设置gRPC中间件
type Server ¶
Server 是gRPC服务器
func (*Server) RegisterService ¶
func (s *Server) RegisterService(sd *grpc.ServiceDesc, ss interface{})
RegisterService 注册gRPC服务
func (*Server) UseMiddleware ¶
func (s *Server) UseMiddleware(m ...middleware.Middleware)
UseMiddleware 在gRPC服务器上使用phantasm中间件
type ServerOption ¶
type ServerOption func(*Server)
ServerOption 是gRPC服务器选项
func Address ¶
func Address(address string) ServerOption
Address 设置地址,例如 ":9000", "127.0.0.1:9000" 等
func Network ¶
func Network(network string) ServerOption
Network 设置网络类型,例如 "tcp", "tcp4", "tcp6", "unix" 或 "unixpacket"
func WithStreamServerInterceptors ¶
func WithStreamServerInterceptors(interceptors ...grpc.StreamServerInterceptor) ServerOption
WithStreamServerInterceptors 添加gRPC流拦截器选项
func WithUnaryServerInterceptors ¶
func WithUnaryServerInterceptors(interceptors ...grpc.UnaryServerInterceptor) ServerOption
WithUnaryServerInterceptors 添加gRPC一元拦截器选项