Documentation
¶
Index ¶
- func GetStream(ctx context.Context) grpc.ServerStream
- func NewClient(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, error)
- func NewWrappedStream(ctx context.Context, stream grpc.ServerStream, m matcher.Matcher) grpc.ServerStream
- type ClientOption
- func WithDiscovery(d registry.Discovery) ClientOption
- func WithEndpoint(endpoint string) ClientOption
- func WithHealthCheck(healthCheck bool) ClientOption
- func WithMiddleware(m ...middleware.Middleware) ClientOption
- func WithNodeFilter(filters ...selector.NodeFilter) ClientOption
- func WithOptions(opts ...grpc.DialOption) ClientOption
- func WithStreamInterceptor(in ...grpc.StreamClientInterceptor) ClientOption
- func WithStreamMiddleware(m ...middleware.Middleware) ClientOption
- func WithSubset(size int) ClientOption
- func WithTLSConfig(c *tls.Config) ClientOption
- func WithTimeout(timeout time.Duration) ClientOption
- func WithUnaryInterceptor(in ...grpc.UnaryClientInterceptor) ClientOption
- type Server
- type ServerOption
- func AccessLog(cfg logx.AccessLogConfig) ServerOption
- func Address(addr string) ServerOption
- func CustomHealth() ServerOption
- func DisableReflection() ServerOption
- func Endpoint(endpoint *url.URL) ServerOption
- func Listener(lis net.Listener) ServerOption
- func Logger(logger logx.Logger) ServerOption
- func Metrics(m metricsx.Manager) ServerOption
- func Middleware(m ...middleware.Middleware) ServerOption
- func Network(network string) ServerOption
- func Options(opts ...grpc.ServerOption) ServerOption
- func StreamInterceptor(in ...grpc.StreamServerInterceptor) ServerOption
- func StreamMiddleware(m ...middleware.Middleware) ServerOption
- func TLSConfig(c *tls.Config) ServerOption
- func Timeout(timeout time.Duration) ServerOption
- func UnaryInterceptor(in ...grpc.UnaryServerInterceptor) ServerOption
- type Trailer
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, error)
NewClient returns a gRPC client connection.
func NewWrappedStream ¶
func NewWrappedStream(ctx context.Context, stream grpc.ServerStream, m matcher.Matcher) grpc.ServerStream
Types ¶
type ClientOption ¶
type ClientOption func(o *clientOptions)
ClientOption is gRPC client option.
func WithDiscovery ¶
func WithDiscovery(d registry.Discovery) ClientOption
WithDiscovery with client discovery.
func WithEndpoint ¶
func WithEndpoint(endpoint string) ClientOption
WithEndpoint with client endpoint.
func WithHealthCheck ¶
func WithHealthCheck(healthCheck bool) ClientOption
WithHealthCheck with health check
func WithMiddleware ¶
func WithMiddleware(m ...middleware.Middleware) ClientOption
WithMiddleware with client middleware.
func WithNodeFilter ¶
func WithNodeFilter(filters ...selector.NodeFilter) ClientOption
WithNodeFilter with select filters
func WithOptions ¶
func WithOptions(opts ...grpc.DialOption) ClientOption
WithOptions with gRPC options.
func WithStreamInterceptor ¶
func WithStreamInterceptor(in ...grpc.StreamClientInterceptor) ClientOption
WithStreamInterceptor returns a ClientOption that specifies the interceptor for streaming RPCs.
func WithStreamMiddleware ¶
func WithStreamMiddleware(m ...middleware.Middleware) ClientOption
WithStreamMiddleware with client stream middleware.
func WithSubset ¶
func WithSubset(size int) ClientOption
WithSubset with client discovery subset size. zero value means subset filter disabled
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout with client timeout.
func WithUnaryInterceptor ¶
func WithUnaryInterceptor(in ...grpc.UnaryClientInterceptor) ClientOption
WithUnaryInterceptor returns a ClientOption that specifies the interceptor for unary RPCs.
type Server ¶
Server is a gRPC server wrapper.
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
NewServer creates a gRPC server by options.
func (*Server) Endpoint ¶
Endpoint return a real address to registry endpoint. examples:
grpc://127.0.0.1:9000?isSecure=false
func (*Server) Use ¶
func (s *Server) Use(selector string, m ...middleware.Middleware)
Use uses a service middleware with selector. selector:
- '/*'
- '/helloworld.v1.Greeter/*'
- '/helloworld.v1.Greeter/SayHello'
type ServerOption ¶
type ServerOption func(o *Server)
ServerOption is gRPC server option.
func AccessLog ¶ added in v0.0.5
func AccessLog(cfg logx.AccessLogConfig) ServerOption
AccessLog configures the built-in gRPC access log. Only Enabled and SlowThreshold are used for gRPC.
func DisableReflection ¶
func DisableReflection() ServerOption
DisableReflection disable grpc reflection.
func Logger ¶ added in v0.0.5
func Logger(logger logx.Logger) ServerOption
Logger sets the logx logger used by built-in gRPC access/error logs.
func Metrics ¶ added in v0.0.5
func Metrics(m metricsx.Manager) ServerOption
Metrics enables built-in low-cardinality gRPC server metrics.
func Middleware ¶
func Middleware(m ...middleware.Middleware) ServerOption
Middleware with server middleware.
func StreamInterceptor ¶
func StreamInterceptor(in ...grpc.StreamServerInterceptor) ServerOption
StreamInterceptor returns a ServerOption that sets the StreamServerInterceptor for the server.
func StreamMiddleware ¶
func StreamMiddleware(m ...middleware.Middleware) ServerOption
func UnaryInterceptor ¶
func UnaryInterceptor(in ...grpc.UnaryServerInterceptor) ServerOption
UnaryInterceptor returns a ServerOption that sets the UnaryServerInterceptor for the server.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is a gRPC transport.
func (*Transport) NodeFilters ¶
func (tr *Transport) NodeFilters() []selector.NodeFilter
NodeFilters returns the client select filters.
func (*Transport) ReplyHeader ¶
ReplyHeader returns the reply header.
func (*Transport) RequestHeader ¶
RequestHeader returns the request header.