Documentation
¶
Index ¶
- Constants
- Variables
- func DialTCP(address string) (*net.TCPConn, error)
- func ListenTCP(address string) (*net.TCPListener, error)
- func NewError(err error, endpoint choykit.Endpoint) error
- func NewFakeConn(node choykit.NodeID, addr string) choykit.Endpoint
- func ReadProtoMessage(conn net.Conn, cdec choykit.Codec, msgOut proto.Message) (*choykit.Packet, error)
- func RequestMessage(conn net.Conn, cdec choykit.Codec, reqCommand int32, ...) error
- func SendPacketMessage(conn net.Conn, cdec choykit.Codec, pkt *choykit.Packet) error
- func SendProtoMessage(conn net.Conn, cdec choykit.Codec, command int32, msgIn proto.Message) error
- type ConnBase
- func (c *ConnBase) Codec() choykit.Codec
- func (c *ConnBase) Context() *choykit.ServiceContext
- func (c *ConnBase) IsClosing() bool
- func (c *ConnBase) NodeID() choykit.NodeID
- func (c *ConnBase) RemoteAddr() string
- func (c *ConnBase) SetContext(v *choykit.ServiceContext)
- func (c *ConnBase) SetNodeID(node choykit.NodeID)
- func (c *ConnBase) SetRemoteAddr(addr string)
- func (c *ConnBase) SetUserData(ud interface{})
- func (c *ConnBase) Stats() *choykit.Stats
- func (c *ConnBase) UserData() interface{}
- type Error
- type FakeConn
- type RpcContext
- type RpcFactory
- func (r *RpcFactory) Call(node choykit.NodeID, request, reply int32, body proto.Message) *RpcContext
- func (r *RpcFactory) CallAsync(node choykit.NodeID, request, reply int32, body proto.Message, cb RpcHandler) *RpcContext
- func (r *RpcFactory) Go()
- func (r *RpcFactory) Init(ctx *choykit.ServiceContext) error
- func (r *RpcFactory) Shutdown()
- type RpcHandler
- type TcpConn
- type TcpServer
- type WsConn
- type WsServer
Constants ¶
View Source
const ( StatBytesRecv int = iota // bytes received StatBytesSent // bytes sent StatPacketsRecv // packets received StatPacketsSent // packets sent NumStat )
View Source
const (
WSCONN_MAX_PAYLOAD = 16 * 1024 // 16k
)
Variables ¶
View Source
var ( ErrConnIsClosing = errors.New("connection is closing when sending") ErrConnOutboundOverflow = errors.New("connection outbound queue overflow") ErrConnForceClose = errors.New("connection forced to close") )
View Source
var (
RequestReadTimeout = 15
)
View Source
var (
TConnReadTimeout = 60
)
View Source
var (
WSConnReadTimeout = 100 * time.Second
)
Functions ¶
func NewFakeConn ¶
func NewFakeConn(node choykit.NodeID, addr string) choykit.Endpoint
func ReadProtoMessage ¶ added in v1.0.2
func RequestMessage ¶ added in v1.0.2
func RequestMessage(conn net.Conn, cdec choykit.Codec, reqCommand int32, msgReq, msgResp proto.Message) error
send request message and wait for response message
func SendPacketMessage ¶ added in v1.0.2
Types ¶
type ConnBase ¶
type ConnBase struct {
// contains filtered or unexported fields
}
func (*ConnBase) RemoteAddr ¶
func (*ConnBase) SetContext ¶
func (c *ConnBase) SetContext(v *choykit.ServiceContext)
func (*ConnBase) SetRemoteAddr ¶
func (*ConnBase) SetUserData ¶
func (c *ConnBase) SetUserData(ud interface{})
type FakeConn ¶
type FakeConn struct {
ConnBase
}
a fake endpoint
func (*FakeConn) ForceClose ¶
func (*FakeConn) SendPacket ¶
type RpcContext ¶
type RpcContext struct {
// contains filtered or unexported fields
}
RPC上下文
func NewRpcContext ¶
func NewRpcContext(node choykit.NodeID, request, reply int32, body interface{}, handler RpcHandler) *RpcContext
func (*RpcContext) Body ¶
func (r *RpcContext) Body() interface{}
func (*RpcContext) Done ¶
func (r *RpcContext) Done(ec uint32, body interface{})
func (*RpcContext) Errno ¶
func (r *RpcContext) Errno() uint32
func (*RpcContext) NodeID ¶ added in v1.0.2
func (r *RpcContext) NodeID() choykit.NodeID
func (*RpcContext) Run ¶
func (r *RpcContext) Run() error
func (*RpcContext) Succeed ¶
func (r *RpcContext) Succeed() bool
type RpcFactory ¶
RPC工厂
func (*RpcFactory) Call ¶
func (r *RpcFactory) Call(node choykit.NodeID, request, reply int32, body proto.Message) *RpcContext
同步RPC
func (*RpcFactory) CallAsync ¶
func (r *RpcFactory) CallAsync(node choykit.NodeID, request, reply int32, body proto.Message, cb RpcHandler) *RpcContext
异步RPC
func (*RpcFactory) Go ¶
func (r *RpcFactory) Go()
func (*RpcFactory) Init ¶
func (r *RpcFactory) Init(ctx *choykit.ServiceContext) error
func (*RpcFactory) Shutdown ¶
func (r *RpcFactory) Shutdown()
type RpcHandler ¶
type RpcHandler func(*RpcContext) error
type TcpConn ¶
type TcpConn struct { ConnBase // contains filtered or unexported fields }
TCP connection
func NewTcpConn ¶
func (*TcpConn) ForceClose ¶
func (*TcpConn) OutboundQueue ¶
func (t *TcpConn) OutboundQueue() chan *choykit.Packet
func (*TcpConn) SendPacket ¶
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewTcpServer ¶
func (*TcpServer) BacklogChan ¶
func (s *TcpServer) BacklogChan() chan choykit.Endpoint
type WsConn ¶
type WsConn struct { ConnBase // contains filtered or unexported fields }
Websocket connection
func (*WsConn) ForceClose ¶
func (*WsConn) ReadPacket ¶ added in v0.2.2
func (*WsConn) SendPacket ¶
type WsServer ¶
type WsServer struct {
// contains filtered or unexported fields
}
Websocket server
func NewWebsocketServer ¶
func (*WsServer) BacklogChan ¶
Click to show internal directories.
Click to hide internal directories.