Jrpc

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const ConstRpcHeader = "rpc-header-bin"

metadata如果要传输二进制数据,key必须以bin结尾

View Source
const ConstRpcStreamClientHeader = "rpc-stream-client-header-bin"

metadata如果要传输二进制数据,key必须以bin结尾

View Source
const ConstRpcStreamServerHeader = "rpc-stream-server-header-bin"
View Source
const ConstRpcStreamServerTrailer = "rpc-stream-server-trailer-bin"

Variables

This section is empty.

Functions

func GrpcClientInit

func GrpcClientInit(config RpcClientConfig) (*grpc.ClientConn, error)

func GrpcServerInit

func GrpcServerInit(config RpcServerConfig) (*grpc.Server, error)

func RegisterRpcKeepalive

func RegisterRpcKeepalive(rpcKeepalive *RpcKeepalive, call RpcKeepaliveCall) error

func SetRpcStreamClientHeader

func SetRpcStreamClientHeader(data []byte) context.Context

设置Rpc流元数据

Types

type RpcBaseConfig

type RpcBaseConfig struct {
	Addr          string
	PublicKeyPath string
}

type RpcClientConfig

type RpcClientConfig struct {
	RpcBaseConfig
	CertName       string
	Header         []byte
	ConnectTimeOut time.Duration
	ClientOption   []grpc.DialOption
}

type RpcContext

type RpcContext struct {
	RpcHeader              []byte
	RpcStreamClientHeader  []byte
	RpcStreamServerTrailer []byte
	RpcStreamServerHeader  []byte
	RpcClientAddr          string
}

func ParseRpcContext

func ParseRpcContext(ctx context.Context) (RpcContext, error)

获取连接参数

type RpcKeepalive

type RpcKeepalive struct {
	Data          interface{}
	Conn          *grpc.ClientConn
	KeepaliveTime time.Duration
	// contains filtered or unexported fields
}

func (*RpcKeepalive) Close

func (rpc *RpcKeepalive) Close()

type RpcKeepaliveCall

type RpcKeepaliveCall interface {
	RpcServeConnected(client *RpcKeepalive, isReConnect bool)
	RpcServeDisconnected(client *RpcKeepalive, isCloseByUser bool)
}

type RpcServerConfig

type RpcServerConfig struct {
	RpcBaseConfig
	PrivateKeyPath string
	RegisterCall   func(*grpc.Server)
	LogWrite       io.Writer
	ServerOption   []grpc.ServerOption
}

type RpcStream

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

func GrpcStreamClientInit

func GrpcStreamClientInit(recvMsgProto proto.Message, call RpcStreamCall) (*RpcStream, error)

初始化rpc流客户端

func GrpcStreamServerInit

func GrpcStreamServerInit(stream grpc.ServerStream, recvMsgProto proto.Message, call RpcStreamCall) (*RpcStream, error)

初始化rpc流服务

func (*RpcStream) Close

func (rpc *RpcStream) Close(immediately bool)

func (*RpcStream) GetBindVal

func (rpc *RpcStream) GetBindVal() interface{}

获取绑定值

func (*RpcStream) GetRpcContext

func (rpc *RpcStream) GetRpcContext() RpcContext

获取参数值

func (*RpcStream) GrpcStreamClientRun

func (rpc *RpcStream) GrpcStreamClientRun(stream grpc.ClientStream) error

运行rpc流客户端

func (*RpcStream) GrpcStreamServerRun

func (rpc *RpcStream) GrpcStreamServerRun(stream grpc.ServerStream) error

运行rpc流服务

func (*RpcStream) SendData

func (rpc *RpcStream) SendData(data interface{})

发送rpc数据

func (*RpcStream) WriteRpcStreamClientHeader

func (rpc *RpcStream) WriteRpcStreamClientHeader(data []byte)

设置rpc流客户端数据

func (*RpcStream) WriteRpcStreamServerHeader

func (rpc *RpcStream) WriteRpcStreamServerHeader(data []byte)

设置rpc流客户端数据

type RpcStreamCall

type RpcStreamCall struct {
	RpcStreamConnect   func(conn *RpcStream) (interface{}, error)
	RpcStreamConnected func(conn *RpcStream) error
	RpcStreamClosed    func(conn *RpcStream) error
	RpcStreamReceiver  func(conn *RpcStream, recv interface{}) error
	RpcStreamError     func(text string, err error)
}

Jump to

Keyboard shortcuts

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