Documentation ¶
Index ¶
- func NewConn(target string, opt ...grpc.DialOption) (*grpc.ClientConn, error)
- type ClientConfig
- type RpcClient
- func (c *RpcClient) Dial(ctx context.Context, target string, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)
- func (c *RpcClient) DialTLS(ctx context.Context, target string, file string, name string, ...) (conn *grpc.ClientConn, err error)
- func (c *RpcClient) SetConfig(conf *ClientConfig) (err error)
- func (c *RpcClient) Use(handlers ...grpc.UnaryClientInterceptor) *RpcClient
- func (c *RpcClient) UseOpt(opts ...grpc.DialOption) *RpcClient
- type RpcServer
- func (s *RpcServer) Run(addr string) error
- func (s *RpcServer) Serve(lis net.Listener) error
- func (s *RpcServer) Server() *grpc.Server
- func (s *RpcServer) SetConfig(config *RpcServerConfig) (err error)
- func (s *RpcServer) Shutdown(ctx context.Context) (err error)
- func (s *RpcServer) Start() (*RpcServer, error)
- func (s *RpcServer) Use(handlers ...grpc.UnaryServerInterceptor) *RpcServer
- type RpcServerConfig
- type TimeoutCallOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConn ¶
func NewConn(target string, opt ...grpc.DialOption) (*grpc.ClientConn, error)
Types ¶
type ClientConfig ¶
type RpcClient ¶
type RpcClient struct {
// contains filtered or unexported fields
}
func DefaultClient ¶
func DefaultClient() *RpcClient
func NewClient ¶
func NewClient(conf *ClientConfig, opt ...grpc.DialOption) *RpcClient
func (*RpcClient) Dial ¶
func (c *RpcClient) Dial(ctx context.Context, target string, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)
func (*RpcClient) SetConfig ¶
func (c *RpcClient) SetConfig(conf *ClientConfig) (err error)
SetConfig hot reloads client config
type RpcServer ¶
type RpcServer struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(config *RpcServerConfig, opt ...grpc.ServerOption) (s *RpcServer)
NewServer returns a new blank Server instance with a default server interceptor.
func (*RpcServer) Run ¶
Run create a tcp listener and start goroutine for serving each incoming request. Run will return a non-nil error unless Stop or GracefulStop is called.
func (*RpcServer) Serve ¶
Serve accepts incoming connections on the listener lis, creating a new ServerTransport and service goroutine for each. Serve will return a non-nil error unless Stop or GracefulStop is called.
func (*RpcServer) SetConfig ¶
func (s *RpcServer) SetConfig(config *RpcServerConfig) (err error)
SetConfig hot reloads server config
type RpcServerConfig ¶
type RpcServerConfig struct { Addr string Timeout ztime.Duration IdleTimeout ztime.Duration MaxLifeTime ztime.Duration ForceCloseWait ztime.Duration KeepAliveInterval ztime.Duration KeepAliveTimeout ztime.Duration }
func DefaultRpcServerConfig ¶
func DefaultRpcServerConfig() *RpcServerConfig
type TimeoutCallOption ¶
type TimeoutCallOption struct { *grpc.EmptyCallOption Timeout ztime.Duration }
func WithTimeoutCallOption ¶
func WithTimeoutCallOption(timeout ztime.Duration) *TimeoutCallOption
Click to show internal directories.
Click to hide internal directories.