Documentation ¶
Index ¶
- Variables
- type BaseTransportClient
- type ChannelHandler
- type ClientOption
- type ClientOptions
- type ConnectEvent
- type ConnectEventListener
- type ConnectEventType
- type ConnectType
- type DefaultEndpointRepository
- type Dispatcher
- type Endpoint
- type EndpointRepository
- type ProxyConn
- func (c *ProxyConn) Close() error
- func (c *ProxyConn) LocalAddr() net.Addr
- func (c *ProxyConn) Read(b []byte) (n int, err error)
- func (c *ProxyConn) RemoteAddr() net.Addr
- func (c *ProxyConn) SetDeadline(t time.Time) error
- func (c *ProxyConn) SetReadDeadline(t time.Time) error
- func (c *ProxyConn) SetWriteDeadline(t time.Time) error
- func (c *ProxyConn) Write(b []byte) (n int, err error)
- type RpcClientContext
- type RpcServerContext
- type ServerOption
- type ServerOptions
- type ServerRequest
- func (*ServerRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ServerRequest) GetBody() *anypb.Any
- func (x *ServerRequest) GetFunName() string
- func (x *ServerRequest) GetHeader() map[string]string
- func (x *ServerRequest) GetRequestId() string
- func (*ServerRequest) ProtoMessage()
- func (x *ServerRequest) ProtoReflect() protoreflect.Message
- func (x *ServerRequest) Reset()
- func (x *ServerRequest) String() string
- type ServerResponse
- func (*ServerResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ServerResponse) GetBody() *anypb.Any
- func (x *ServerResponse) GetCode() int32
- func (x *ServerResponse) GetFunName() string
- func (x *ServerResponse) GetHeader() map[string]string
- func (x *ServerResponse) GetMsg() string
- func (x *ServerResponse) GetRequestId() string
- func (*ServerResponse) ProtoMessage()
- func (x *ServerResponse) ProtoReflect() protoreflect.Message
- func (x *ServerResponse) Reset()
- func (x *ServerResponse) String() string
- type SimpleHandler
- type TransportClient
- type TransportServer
- type UserCall
Constants ¶
This section is empty.
Variables ¶
View Source
var File_rpc_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type BaseTransportClient ¶
type BaseTransportClient struct { EventChan chan ConnectEvent Watchers []ConnectEventListener Filters []func(req *ServerRequest) CancelFs []context.CancelFunc // contains filtered or unexported fields }
func NewBaseClient ¶
func NewBaseClient() *BaseTransportClient
func (*BaseTransportClient) AddChain ¶
func (btc *BaseTransportClient) AddChain(filter func(req *ServerRequest))
func (*BaseTransportClient) AddWatcher ¶
func (btc *BaseTransportClient) AddWatcher(watcher ConnectEventListener)
func (*BaseTransportClient) DoFilter ¶
func (btc *BaseTransportClient) DoFilter(req *ServerRequest)
type ChannelHandler ¶
type ChannelHandler func(cxt context.Context, rpcCtx RpcServerContext)
type ClientOption ¶
type ClientOption struct { ConnectType ConnectType OpenTSL bool }
type ClientOptions ¶
type ClientOptions func(opt *ClientOption)
type ConnectEvent ¶
type ConnectEvent struct { EventType ConnectEventType Conn net.Conn }
type ConnectEventListener ¶
type ConnectEventListener func(eventType ConnectEventType, con net.Conn)
type ConnectEventType ¶
type ConnectEventType int8
const ( ConnectEventForConnected ConnectEventType = iota ConnectEventForDisConnected )
func (ConnectEventType) String ¶
func (i ConnectEventType) String() string
type ConnectType ¶
type ConnectType string
ConnectType 连接类型
const ( ConnectTypeRSocket ConnectType = "RSocket" ConnectWebSocket ConnectType = "WebSocket" ConnectGrpc ConnectType = "gRPC" )
type DefaultEndpointRepository ¶
type DefaultEndpointRepository struct {
// contains filtered or unexported fields
}
EndpointRepository 管理实例的仓库
func (*DefaultEndpointRepository) Put ¶
func (erp *DefaultEndpointRepository) Put(name string, endpoint Endpoint)
Put 为某个服务添加一个服务实例
func (*DefaultEndpointRepository) Remove ¶
func (erp *DefaultEndpointRepository) Remove(name string, endpoint Endpoint)
Remove 从某个服务中移除实例
type Dispatcher ¶
type Dispatcher struct { Label string // contains filtered or unexported fields }
func NewDispatcher ¶
func NewDispatcher(label string) Dispatcher
func (*Dispatcher) FindChannelHandler ¶
func (r *Dispatcher) FindChannelHandler(key string) ChannelHandler
func (*Dispatcher) FindSimpleHandler ¶
func (r *Dispatcher) FindSimpleHandler(key string) SimpleHandler
func (*Dispatcher) RegisterChannelHandler ¶
func (r *Dispatcher) RegisterChannelHandler(key string, handler ChannelHandler) bool
func (*Dispatcher) RegisterSimpleHandler ¶
func (r *Dispatcher) RegisterSimpleHandler(key string, handler SimpleHandler) bool
type Endpoint ¶
type Endpoint struct { Key string Host string Port int32 // contains filtered or unexported fields }
Endpoint 实例的链接信息
type EndpointRepository ¶
type EndpointRepository interface { //SelectOne 选择一个服务的实例进行随机访问 SelectOne(name string) (bool, Endpoint) //Put 为某个服务添加一个服务实例 Put(name string, endpoint Endpoint) //Remove 从某个服务中移除实例 Remove(name string, endpoint Endpoint) }
func NewDefaultEndpointRepository ¶
func NewDefaultEndpointRepository() EndpointRepository
NewDefaultEndpointRepository 创建一个默认的 EndpointRepository
type ProxyConn ¶
func (*ProxyConn) RemoteAddr ¶
type RpcClientContext ¶
type RpcClientContext interface { io.Closer Send(resp *ServerRequest) Receive() (<-chan *ServerResponse, <-chan error) }
RpcClientContext Client端对于一个请求的发送
type RpcServerContext ¶
type RpcServerContext interface { io.Closer GetReq() *ServerRequest Send(resp *ServerResponse) error }
RpcServerContext Server端对于一个请求的上下文
type ServerOption ¶
type ServerOption struct { ConnectType ConnectType Label string Port int32 OpenTSL bool }
type ServerOptions ¶
type ServerOptions func(opt *ServerOption)
type ServerRequest ¶
type ServerRequest struct { FunName string `protobuf:"bytes,1,opt,name=FunName,proto3" json:"FunName,omitempty"` Body *anypb.Any `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"` RequestId string `protobuf:"bytes,3,opt,name=requestId,proto3" json:"requestId,omitempty"` Header map[string]string `` /* 153-byte string literal not displayed */ // contains filtered or unexported fields }
func (*ServerRequest) Descriptor
deprecated
func (*ServerRequest) Descriptor() ([]byte, []int)
Deprecated: Use ServerRequest.ProtoReflect.Descriptor instead.
func (*ServerRequest) GetBody ¶
func (x *ServerRequest) GetBody() *anypb.Any
func (*ServerRequest) GetFunName ¶
func (x *ServerRequest) GetFunName() string
func (*ServerRequest) GetHeader ¶
func (x *ServerRequest) GetHeader() map[string]string
func (*ServerRequest) GetRequestId ¶
func (x *ServerRequest) GetRequestId() string
func (*ServerRequest) ProtoMessage ¶
func (*ServerRequest) ProtoMessage()
func (*ServerRequest) ProtoReflect ¶
func (x *ServerRequest) ProtoReflect() protoreflect.Message
func (*ServerRequest) Reset ¶
func (x *ServerRequest) Reset()
func (*ServerRequest) String ¶
func (x *ServerRequest) String() string
type ServerResponse ¶
type ServerResponse struct { FunName string `protobuf:"bytes,1,opt,name=FunName,proto3" json:"FunName,omitempty"` RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` Header map[string]string `` /* 153-byte string literal not displayed */ Code int32 `protobuf:"varint,3,opt,name=code,proto3" json:"code,omitempty"` Body *anypb.Any `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` Msg string `protobuf:"bytes,6,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*ServerResponse) Descriptor
deprecated
func (*ServerResponse) Descriptor() ([]byte, []int)
Deprecated: Use ServerResponse.ProtoReflect.Descriptor instead.
func (*ServerResponse) GetBody ¶
func (x *ServerResponse) GetBody() *anypb.Any
func (*ServerResponse) GetCode ¶
func (x *ServerResponse) GetCode() int32
func (*ServerResponse) GetFunName ¶
func (x *ServerResponse) GetFunName() string
func (*ServerResponse) GetHeader ¶
func (x *ServerResponse) GetHeader() map[string]string
func (*ServerResponse) GetMsg ¶
func (x *ServerResponse) GetMsg() string
func (*ServerResponse) GetRequestId ¶
func (x *ServerResponse) GetRequestId() string
func (*ServerResponse) ProtoMessage ¶
func (*ServerResponse) ProtoMessage()
func (*ServerResponse) ProtoReflect ¶
func (x *ServerResponse) ProtoReflect() protoreflect.Message
func (*ServerResponse) Reset ¶
func (x *ServerResponse) Reset()
func (*ServerResponse) String ¶
func (x *ServerResponse) String() string
type SimpleHandler ¶
type SimpleHandler func(cxt context.Context, rpcCtx RpcServerContext)
type TransportClient ¶
type TransportClient interface { //RegisterConnectEventWatcher 客户端监听和服务端的会话的状态 RegisterConnectEventWatcher(watcher func(eventType ConnectEventType, conn net.Conn)) //CheckConnection 检查链接 CheckConnection(endpoint Endpoint) (bool, error) //AddChain 添加请求处理链 AddChain(filter func(req *ServerRequest)) //Request 发起 request-response 请求 Request(ctx context.Context, endpoint Endpoint, req *ServerRequest) (*ServerResponse, error) //RequestChannel 发起 request-channel 请求 RequestChannel(ctx context.Context, endpoint Endpoint) (RpcClientContext, error) //Close 关闭客户端 Close() error }
TransportClient 客户端调用接口
type TransportServer ¶
type TransportServer interface { //AddConnectEventListener 服务端的监听和客户端的会话的状态 AddConnectEventListener(listener ConnectEventListener) //RemoveConnectEventListener RemoveConnectEventListener(listener ConnectEventListener) //RegisterSimpleHandler 注册一个 Request-Response的Server端处理者,名称为name RegisterSimpleHandler(funName string, handler SimpleHandler) //RegisterChannelHandler 注册一个 Request-Channel的Server端处理者,名称为name RegisterChannelHandler(funName string, handler ChannelHandler) }
TransportServer 服务端接口
type UserCall ¶
type UserCall func(resp *ServerResponse, err error)
Click to show internal directories.
Click to hide internal directories.