zrpc

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// WithDialOption is an alias of internal.WithDialOption.
	WithDialOption = internal.WithDialOption
	// WithTimeout is an alias of internal.WithTimeout.
	WithTimeout = internal.WithTimeout
	// WithUnaryClientInterceptor is an alias of internal.WithUnaryClientInterceptor.
	WithUnaryClientInterceptor = internal.WithUnaryClientInterceptor
)

Functions

This section is empty.

Types

type Client

type Client = internal.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 NewClientNoAuth

func NewClientNoAuth(c discov.EtcdConf, opts ...ClientOption) (Client, error)

NewClientNoAuth returns a Client without authentication.

func NewClientWithTarget

func NewClientWithTarget(target string, opts ...ClientOption) (Client, error)

NewClientWithTarget returns a Client with connecting to given target.

type ClientOption added in v1.0.18

type ClientOption = internal.ClientOption

ClientOption is an alias of internal.ClientOption.

type RpcClient

type RpcClient struct {
	// contains filtered or unexported fields
}

A RpcClient is a rpc client.

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"`
	Endpoints []string        `json:",optional"`
	Target    string          `json:",optional"`
	App       string          `json:",optional"`
	Token     string          `json:",optional"`
	Timeout   int64           `json:",default=2000"`
}

A RpcClientConf is a rpc client config.

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) 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.

func NewProxy

func NewProxy(backend string, opts ...internal.ClientOption) *RpcProxy

NewProxy returns a RpcProxy.

func (*RpcProxy) TakeConn

func (p *RpcProxy) TakeConn(ctx context.Context) (*grpc.ClientConn, error)

TakeConn returns a grpc.ClientConn.

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 added in v1.0.17

func (rs *RpcServer) AddOptions(options ...grpc.ServerOption)

AddOptions adds given options.

func (*RpcServer) AddStreamInterceptors added in v1.0.17

func (rs *RpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)

AddStreamInterceptors adds given stream interceptors.

func (*RpcServer) AddUnaryInterceptors added in v1.0.17

func (rs *RpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)

AddUnaryInterceptors adds given unary interceptors.

func (*RpcServer) Start

func (rs *RpcServer) Start()

Start starts the RpcServer. Graceful shutdown is enabled by default. Use proc.SetTimeToForceQuit to customize the graceful shutdown period.

func (*RpcServer) Stop

func (rs *RpcServer) Stop()

Stop stops the RpcServer.

type RpcServerConf

type RpcServerConf struct {
	service.ServiceConf
	ListenOn      string
	Etcd          discov.EtcdConf    `json:",optional"`
	Auth          bool               `json:",optional"`
	Redis         redis.RedisKeyConf `json:",optional"`
	StrictControl bool               `json:",optional"`
	// setting 0 means no timeout
	Timeout      int64 `json:",default=2000"`
	CpuThreshold int64 `json:",default=900,range=[0:1000]"`
}

A RpcServerConf is a rpc server config.

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.

Directories

Path Synopsis
mock
Package mock is a generated protocol buffer package.
Package mock is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL