Documentation ¶
Index ¶
- Constants
- Variables
- func DialTCP(address string) (*net.TCPConn, error)
- func ListenTCP(address string) (*net.TCPListener, error)
- func NewError(err error, endpoint fatchoy.Endpoint) error
- func NewFakeConn(node fatchoy.NodeID, addr string) fatchoy.Endpoint
- func ReadPacketMessage(conn net.Conn, decoder fatchoy.ProtocolDecoder, decrypt cipher.BlockCryptor, ...) error
- func ReadProtoMessage(conn net.Conn, decoder fatchoy.ProtocolDecoder, decrypt cipher.BlockCryptor, ...) error
- func RequestMessage(conn net.Conn, encoder fatchoy.ProtocolCodec, encrypt cipher.BlockCryptor, ...) error
- func SendPacketMessage(conn net.Conn, encoder fatchoy.ProtocolEncoder, encrypt cipher.BlockCryptor, ...) error
- func SendProtoMessage(conn net.Conn, encoder fatchoy.ProtocolCodec, encrypt cipher.BlockCryptor, ...) error
- 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) 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
- func (r *RpcFactory) Call(node fatchoy.NodeID, request, reply int32, body proto.Message) *RpcContext
- func (r *RpcFactory) CallAsync(node fatchoy.NodeID, request, reply int32, body proto.Message, cb RpcHandler) *RpcContext
- func (r *RpcFactory) Go()
- func (r *RpcFactory) Init(ctx *fatchoy.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 = 60
)
View Source
var (
TConnReadTimeout = 100
)
View Source
var (
WSConnReadTimeout = 100 * time.Second
)
Functions ¶
func ReadPacketMessage ¶ added in v1.0.5
func ReadPacketMessage(conn net.Conn, decoder fatchoy.ProtocolDecoder, decrypt cipher.BlockCryptor, pkt *fatchoy.Packet) error
recv一个packet
func ReadProtoMessage ¶ added in v1.0.2
func ReadProtoMessage(conn net.Conn, decoder fatchoy.ProtocolDecoder, decrypt cipher.BlockCryptor, pkt *fatchoy.Packet, pbMsg proto.Message) error
recv一条protobuf消息
func RequestMessage ¶ added in v1.0.2
func RequestMessage(conn net.Conn, encoder fatchoy.ProtocolCodec, encrypt cipher.BlockCryptor, reqCommand int32, msgReq, msgResp proto.Message) error
send并且立即等待recv
func SendPacketMessage ¶ added in v1.0.2
func SendPacketMessage(conn net.Conn, encoder fatchoy.ProtocolEncoder, encrypt cipher.BlockCryptor, pkt *fatchoy.Packet) error
send一个packet
func SendProtoMessage ¶ added in v1.0.2
func SendProtoMessage(conn net.Conn, encoder fatchoy.ProtocolCodec, encrypt cipher.BlockCryptor, command int32, outMsg proto.Message) error
send一条protobuf消息
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) 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(node fatchoy.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() fatchoy.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 fatchoy.NodeID, request, reply int32, body proto.Message) *RpcContext
同步RPC
func (*RpcFactory) CallAsync ¶
func (r *RpcFactory) CallAsync(node fatchoy.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 *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 ¶
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.