Documentation
¶
Index ¶
- Constants
- Variables
- func DontLogClientContentForMethod(method string)
- func DontLogContentForMethod(method string)
- func SetClientSlowThreshold(threshold time.Duration)
- func SetHashKey(ctx context.Context, key string) context.Context
- func SetServerSlowThreshold(threshold time.Duration)
- func WithCallTimeout(timeout time.Duration) grpc.CallOption
- func WithRouteTarget(ctx context.Context, instanceID string, mode RouteMode) context.Context
- type Client
- type ClientMiddlewaresConf
- type ClientOption
- type ClientOptions
- type MethodTimeoutConf
- type RouteMode
- type RpcClient
- type RpcClientConf
- type RpcProxy
- type RpcServer
- func (rs *RpcServer) AddOptions(options ...grpc.ServerOption)
- func (rs *RpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
- func (rs *RpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
- func (rs *RpcServer) BeginDrain() error
- func (rs *RpcServer) Start()
- func (rs *RpcServer) Stop()
- type RpcServerConf
- type ServerMiddlewaresConf
- type StatConf
Constants ¶
const ( // RoutePrefer falls back to normal load balancing when the target is unavailable. RoutePrefer = route.Prefer // RouteRequire fails the call when the target is unavailable. RouteRequire = route.Require )
Variables ¶
var ( // WithDialOption is an alias of internal.WithDialOption. WithDialOption = internal.WithDialOption // WithNonBlock sets the dialing to be nonblock. WithNonBlock = internal.WithNonBlock // WithBlock sets the dialing to be blocking. // Deprecated: blocking dials are not recommended by gRPC. WithBlock = internal.WithBlock // WithStreamClientInterceptor is an alias of internal.WithStreamClientInterceptor. WithStreamClientInterceptor = internal.WithStreamClientInterceptor // WithTimeout is an alias of internal.WithTimeout. WithTimeout = internal.WithTimeout // WithTransportCredentials return a func to make the gRPC calls secured with given credentials. WithTransportCredentials = internal.WithTransportCredentials // WithUnaryClientInterceptor is an alias of internal.WithUnaryClientInterceptor. WithUnaryClientInterceptor = internal.WithUnaryClientInterceptor )
var Acceptable = codes.Acceptable
Functions ¶
func DontLogClientContentForMethod ¶
func DontLogClientContentForMethod(method string)
DontLogClientContentForMethod disable logging content for given method.
func DontLogContentForMethod ¶
func DontLogContentForMethod(method string)
DontLogContentForMethod disable logging content for given method. Deprecated: use ServerMiddlewaresConf.IgnoreContentMethods instead.
func SetClientSlowThreshold ¶
SetClientSlowThreshold sets the slow threshold on client side.
func SetHashKey ¶
SetHashKey sets the hash key into context.
func SetServerSlowThreshold ¶
SetServerSlowThreshold sets the slow threshold on server side. Deprecated: use ServerMiddlewaresConf.SlowThreshold instead.
func WithCallTimeout ¶
func WithCallTimeout(timeout time.Duration) grpc.CallOption
WithCallTimeout return a call option with given timeout to make a method call.
Types ¶
type Client ¶
Client is an alias of internal.Client.
func MustNewClient ¶
func MustNewClient(c RpcClientConf, options ...ClientOption) Client
MustNewClient returns a Client, exits on any error.
func NewClient ¶
func NewClient(c RpcClientConf, options ...ClientOption) (Client, error)
NewClient returns a Client.
func NewClientWithTarget ¶
func NewClientWithTarget(target string, opts ...ClientOption) (Client, error)
NewClientWithTarget returns a Client with connecting to given target.
type ClientMiddlewaresConf ¶
type ClientMiddlewaresConf = internal.ClientMiddlewaresConf
ClientMiddlewaresConf defines whether to use client middlewares.
type ClientOption ¶
type ClientOption = internal.ClientOption
ClientOption is an alias of internal.ClientOption.
type ClientOptions ¶
type ClientOptions = internal.ClientOptions
type MethodTimeoutConf ¶
type MethodTimeoutConf = internal.MethodTimeoutConf
MethodTimeoutConf defines specified timeout for gRPC method.
type RpcClient ¶
type RpcClient struct {
// contains filtered or unexported fields
}
A RpcClient is a rpc client.
func (*RpcClient) Close ¶ added in v0.3.0
Close releases the underlying gRPC connection and discovery subscription.
func (*RpcClient) Conn ¶
func (rc *RpcClient) Conn() *grpc.ClientConn
Conn returns the underlying grpc.ClientConn.
type RpcClientConf ¶
type RpcClientConf struct {
Etcd discov.EtcdConf `json:",optional,inherit"`
Endpoints []string `json:",optional"`
Target string `json:",optional"`
App string `json:",optional"`
Token string `json:",optional"`
// Balancer is kept for backward compatibility. BalancerName takes effect when Balancer is empty.
Balancer string `json:",optional"`
NonBlock bool `json:",optional"`
Timeout int64
KeepaliveTime time.Duration `json:",optional"`
Middlewares ClientMiddlewaresConf
BalancerName string
}
A RpcClientConf is a rpc client config.
func DefaultRpcClientConf ¶
func DefaultRpcClientConf() RpcClientConf
DefaultRpcClientConf returns Hexas RPC client defaults.
func NewDirectClientConf ¶
func NewDirectClientConf(endpoints []string, app, token string) RpcClientConf
NewDirectClientConf returns a RpcClientConf.
func NewEtcdClientConf ¶
func NewEtcdClientConf(hosts []string, key, app, token string) RpcClientConf
NewEtcdClientConf returns a RpcClientConf.
func (RpcClientConf) BuildTarget ¶
func (cc RpcClientConf) BuildTarget() (string, error)
BuildTarget builds the rpc target from the given config.
func (RpcClientConf) HasCredential ¶
func (cc RpcClientConf) HasCredential() bool
HasCredential checks if there is a credential in config.
type RpcProxy ¶
type RpcProxy struct {
// contains filtered or unexported fields
}
A RpcProxy is a rpc proxy.
type RpcServer ¶
type RpcServer struct {
// contains filtered or unexported fields
}
A RpcServer is a rpc server.
func MustNewServer ¶
func MustNewServer(c RpcServerConf, register internal.RegisterFn) *RpcServer
MustNewServer returns a RpcSever, exits on any error.
func NewServer ¶
func NewServer(c RpcServerConf, register internal.RegisterFn) (*RpcServer, error)
NewServer returns a RpcServer.
func (*RpcServer) AddOptions ¶
func (rs *RpcServer) AddOptions(options ...grpc.ServerOption)
AddOptions adds given options.
func (*RpcServer) AddStreamInterceptors ¶
func (rs *RpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
AddStreamInterceptors adds given stream interceptors.
func (*RpcServer) AddUnaryInterceptors ¶
func (rs *RpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
AddUnaryInterceptors adds given unary interceptors.
func (*RpcServer) BeginDrain ¶ added in v0.3.0
BeginDrain removes the server from ordinary load balancing while keeping explicit instance routes available for in-flight state transfer.
type RpcServerConf ¶
type RpcServerConf struct {
service.ServiceConf
ListenOn string
Etcd discov.EtcdConf `json:",optional,inherit"`
Auth bool `json:",optional"`
Redis redis.RedisKeyConf `json:",optional"`
StrictControl bool `json:",optional"`
// setting 0 means no timeout
Timeout int64
CpuThreshold int64
// grpc health check switch
Health bool
Middlewares ServerMiddlewaresConf
// setting specified timeout for gRPC method
MethodTimeouts []MethodTimeoutConf `json:",optional"`
}
A RpcServerConf is a rpc server config.
func DefaultRpcServerConf ¶
func DefaultRpcServerConf() RpcServerConf
DefaultRpcServerConf returns Hexas RPC server defaults.
func (RpcServerConf) HasEtcd ¶
func (sc RpcServerConf) HasEtcd() bool
HasEtcd checks if there is etcd settings in config.
func (RpcServerConf) Validate ¶
func (sc RpcServerConf) Validate() error
Validate validates the config.
type ServerMiddlewaresConf ¶
type ServerMiddlewaresConf = internal.ServerMiddlewaresConf
ServerMiddlewaresConf defines whether to use server middlewares.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package route defines per-call RPC endpoint routing directives.
|
Package route defines per-call RPC endpoint routing directives. |