Documentation ¶
Index ¶
- Constants
- Variables
- func NewError(err error, endpoint fatchoy.Endpoint) error
- func NewFakeConn(node fatchoy.NodeID, addr string) fatchoy.Endpoint
- type ConnBase
- func (c *ConnBase) Context() *fatchoy.ServiceContext
- func (c *ConnBase) Encoder() fatchoy.ProtocolCodec
- func (c *ConnBase) IsClosing() bool
- func (c *ConnBase) NodeID() fatchoy.NodeID
- func (c *ConnBase) RemoteAddr() string
- func (c *ConnBase) SetContext(v *fatchoy.ServiceContext)
- func (c *ConnBase) SetEncryptPair(encrypt cipher.BlockCryptor, decrypt cipher.BlockCryptor)
- func (c *ConnBase) SetNodeID(node fatchoy.NodeID)
- func (c *ConnBase) SetRemoteAddr(addr string)
- func (c *ConnBase) SetUserData(ud interface{})
- func (c *ConnBase) Stats() *fatchoy.Stats
- func (c *ConnBase) UserData() interface{}
- type Error
- type FakeConn
- type RpcContext
- type RpcFactory
- 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 // 消息最大大小
)
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 (
TConnReadTimeout = 100
)
View Source
var (
WSConnReadTimeout = 100 * time.Second
)
Functions ¶
Types ¶
type ConnBase ¶
type ConnBase struct {
// contains filtered or unexported fields
}
TcpConn和WsConn的公共基类
func (*ConnBase) Context ¶
func (c *ConnBase) Context() *fatchoy.ServiceContext
func (*ConnBase) Encoder ¶
func (c *ConnBase) Encoder() fatchoy.ProtocolCodec
func (*ConnBase) RemoteAddr ¶
func (*ConnBase) SetContext ¶
func (c *ConnBase) SetContext(v *fatchoy.ServiceContext)
func (*ConnBase) SetEncryptPair ¶ added in v0.2.6
func (c *ConnBase) SetEncryptPair(encrypt cipher.BlockCryptor, decrypt cipher.BlockCryptor)
func (*ConnBase) SetRemoteAddr ¶
func (*ConnBase) SetUserData ¶
func (c *ConnBase) SetUserData(ud interface{})
type RpcContext ¶
type RpcContext struct {
// contains filtered or unexported fields
}
RPC上下文
func NewRpcContext ¶
func NewRpcContext(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) Run ¶
func (r *RpcContext) Run() error
func (*RpcContext) Succeed ¶
func (r *RpcContext) Succeed() bool
type RpcFactory ¶
RPC工厂
func (*RpcFactory) Call ¶
func (r *RpcFactory) Call(request, reply int32, body proto.Message) *RpcContext
同步RPC
func (*RpcFactory) CallAsync ¶
func (r *RpcFactory) CallAsync(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 *fatchoy.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 ¶
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewTcpServer ¶
func (*TcpServer) BacklogChan ¶
type WsConn ¶
type WsConn struct { ConnBase // contains filtered or unexported fields }
Websocket connection
func (*WsConn) ForceClose ¶
func (*WsConn) ReadPacket ¶ added in v0.2.2
Exported API
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.