Documentation ¶
Index ¶
- type Args
- type CallOption
- type Client
- type ClientConfig
- type ClientConn
- type GroupAddrs
- type HTTP
- func (*HTTP) Descriptor() ([]byte, []int)
- func (m *HTTP) GetBody() string
- func (m *HTTP) GetCookie() map[string]string
- func (m *HTTP) GetHeader() map[string]string
- func (m *HTTP) GetIsHttps() int32
- func (m *HTTP) GetMethod() string
- func (m *HTTP) GetProtocol() string
- func (m *HTTP) GetUri() string
- func (*HTTP) ProtoMessage()
- func (m *HTTP) Reset()
- func (m *HTTP) String() string
- func (m *HTTP) XXX_DiscardUnknown()
- func (m *HTTP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *HTTP) XXX_Merge(src proto.Message)
- func (m *HTTP) XXX_Size() int
- func (m *HTTP) XXX_Unmarshal(b []byte) error
- type HTTPOption
- type Header
- func (*Header) Descriptor() ([]byte, []int)
- func (m *Header) Get(key string) string
- func (m *Header) GetBuvid() string
- func (m *Header) GetCaller() string
- func (m *Header) GetPlatform() string
- func (m *Header) GetSessdata2() string
- func (m *Header) GetSourceGroup() string
- func (m *Header) GetSrc() string
- func (m *Header) GetTraceId() string
- func (m *Header) GetUid() int64
- func (m *Header) GetUserIp() string
- func (*Header) ProtoMessage()
- func (m *Header) Reset()
- func (m *Header) Set(key string, val string)
- func (m *Header) String() string
- func (m *Header) XXX_DiscardUnknown()
- func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Header) XXX_Merge(src proto.Message)
- func (m *Header) XXX_Size() int
- func (m *Header) XXX_Unmarshal(b []byte) error
- type HeaderOption
- type Key
- type Reply
- type TimeoutOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Args ¶
type Args struct { Header *Header `json:"header"` Body interface{} `json:"body"` HTTP interface{} `json:"http"` }
Args .
type CallOption ¶
type CallOption interface {
// contains filtered or unexported methods
}
CallOption ...
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a RPC client.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, version int, serviceMethod string, in proto.Message, out proto.Message, opts ...CallOption) (err error)
Call call the service method, waits for it to complete, and returns its error status. client: {service} serviceMethod: {version}|{controller.method} httpURL: /room/v1/Room/room_init httpURL: /{service}/{version}/{controller}/{method}
func (*Client) CallRaw ¶
func (c *Client) CallRaw(ctx context.Context, version int, serviceMethod string, in *Args, opts ...CallOption) (out *Reply, err error)
CallRaw call the service method, waits for it to complete, and returns reply its error status. this is can be use without protobuf client: {service} serviceMethod: {version}|{controller.method} httpURL: /room/v1/Room/room_init httpURL: /{service}/{version}/{controller}/{method}
type ClientConfig ¶
type ClientConfig struct { AppID string Group string Timeout xtime.Duration ConnTimeout xtime.Duration Addr string // if addr is provided, it will use add, else, use discovery }
ClientConfig client config.
type ClientConn ¶
type ClientConn struct { Timeout time.Duration DialTimeout time.Duration // contains filtered or unexported fields }
ClientConn connect represent a real client connection to a rpc server
func Dial ¶
func Dial(ctx context.Context, network, addr string, timeout time.Duration, connTimeout time.Duration) (*ClientConn, error)
Dial dial a rpc server
func (*ClientConn) Call ¶
func (c *ClientConn) Call(ctx context.Context, version int, serviceMethod string, in, out proto.Message) (err error)
Call call the service method, waits for it to complete, and returns its error status. this is used with protobuf generated msg client: {service} serviceMethod: {version}|{controller.method} httpURL: /room/v1/Room/room_init httpURL: /{service}/{version}/{controller}/{method}
func (*ClientConn) CallRaw ¶
func (c *ClientConn) CallRaw(ctx context.Context, version int, serviceMethod string, in *Args) (out *Reply, err error)
CallRaw call the service method, waits for it to complete, and returns reply its error status. this is can be use without protobuf client: {service} serviceMethod: {version}|{controller.method} httpURL: /room/v1/Room/room_init httpURL: /{service}/{version}/{controller}/{method}
type GroupAddrs ¶
GroupAddrs a map struct storing addrs vary groups
type HTTP ¶
type HTTP struct { IsHttps int32 `protobuf:"varint,1,opt,name=is_https,json=isHttps,proto3" json:"is_https,omitempty"` Body string `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"` Cookie map[string]string `` /* 153-byte string literal not displayed */ Header map[string]string `` /* 153-byte string literal not displayed */ Uri string `protobuf:"bytes,5,opt,name=uri,proto3" json:"uri,omitempty"` Method string `protobuf:"bytes,6,opt,name=method,proto3" json:"method,omitempty"` Protocol string `protobuf:"bytes,7,opt,name=protocol,proto3" json:"protocol,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
http is inside the protocol body {"body":..., "header":..., "http":...} this is used when a proxy forward a http request to a rpc request
func (*HTTP) Descriptor ¶
func (*HTTP) GetIsHttps ¶
func (*HTTP) GetProtocol ¶
func (*HTTP) ProtoMessage ¶
func (*HTTP) ProtoMessage()
func (*HTTP) XXX_DiscardUnknown ¶
func (m *HTTP) XXX_DiscardUnknown()
func (*HTTP) XXX_Unmarshal ¶
type Header ¶
type Header struct { // APP_NAME.xxxxx , when separated by dot, // the first part is always app_name, the rest is undefined Caller string `protobuf:"bytes,1,opt,name=caller,proto3" json:"caller,omitempty"` Uid int64 `protobuf:"varint,2,opt,name=uid,proto3" json:"uid,omitempty"` Platform string `protobuf:"bytes,3,opt,name=platform,proto3" json:"platform,omitempty"` Src string `protobuf:"bytes,4,opt,name=src,proto3" json:"src,omitempty"` TraceId string `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` UserIp string `protobuf:"bytes,7,opt,name=user_ip,json=userIp,proto3" json:"user_ip,omitempty"` SourceGroup string `protobuf:"bytes,8,opt,name=source_group,json=sourceGroup,proto3" json:"source_group,omitempty"` Buvid string `protobuf:"bytes,9,opt,name=buvid,proto3" json:"buvid,omitempty"` // session data, format is http query // such as access_token=abc&SESS_DATA=def Sessdata2 string `protobuf:"bytes,10,opt,name=sessdata2,proto3" json:"sessdata2,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Header) Descriptor ¶
func (*Header) GetPlatform ¶
func (*Header) GetSessdata2 ¶
func (*Header) GetSourceGroup ¶
func (*Header) GetTraceId ¶
func (*Header) ProtoMessage ¶
func (*Header) ProtoMessage()
func (*Header) XXX_DiscardUnknown ¶
func (m *Header) XXX_DiscardUnknown()
func (*Header) XXX_Marshal ¶
func (*Header) XXX_Unmarshal ¶
type HeaderOption ¶
type HeaderOption struct {
Header *Header
}
HeaderOption contains Header for liverpc
type Key ¶
type Key int
Key is ContextKey
const ( // KeyHeader use this in context to pass rpc header field // Depreated 请使用HeaderOption来传递Header KeyHeader Key // KeyTimeout deprecated // Depreated 请使用HTTPOption来传递HTTP KeyTimeout )