Documentation ¶
Index ¶
- Constants
- type Bootstrap
- func (bootstrap *Bootstrap) Bind(host string, port int) *Bootstrap
- func (bootstrap *Bootstrap) Connect(host string, port int) error
- func (bootstrap *Bootstrap) ConnectJoinAddr(addr string) error
- func (bootstrap *Bootstrap) ConnectJoinAddrAndReturn(addr string) (Context, error)
- func (bootstrap *Bootstrap) Context(addr string) Context
- func (bootstrap *Bootstrap) Contexts() []Context
- func (bootstrap *Bootstrap) Debug(v ...interface{})
- func (bootstrap *Bootstrap) Debugf(format string, v ...interface{})
- func (bootstrap *Bootstrap) Disconnect(addr string)
- func (bootstrap *Bootstrap) Error(v ...interface{})
- func (bootstrap *Bootstrap) Errorf(format string, v ...interface{})
- func (bootstrap *Bootstrap) Fatal(v ...interface{})
- func (bootstrap *Bootstrap) Fatalf(format string, v ...interface{})
- func (bootstrap *Bootstrap) HasConnect(addr string) bool
- func (bootstrap *Bootstrap) LogFlush()
- func (bootstrap *Bootstrap) NewRandomConnect(sraddr, sladdr string) (Context, error)
- func (bootstrap *Bootstrap) Notice(v ...interface{})
- func (bootstrap *Bootstrap) Noticef(format string, v ...interface{})
- func (bootstrap *Bootstrap) RegisterContextListener(contextListener ContextListener) *Bootstrap
- func (bootstrap *Bootstrap) RegisterHandler(fns ...Handler) *Bootstrap
- func (bootstrap *Bootstrap) SetIdle(idle int) *Bootstrap
- func (bootstrap *Bootstrap) SetKeepAlive(keepalive bool) *Bootstrap
- func (bootstrap *Bootstrap) Shutdown()
- func (bootstrap *Bootstrap) Size() int
- func (bootstrap *Bootstrap) Sync()
- func (bootstrap *Bootstrap) Trace(v ...interface{})
- func (bootstrap *Bootstrap) Tracef(format string, v ...interface{})
- func (bootstrap *Bootstrap) Warn(v ...interface{})
- func (bootstrap *Bootstrap) Warnf(format string, v ...interface{})
- func (bootstrap *Bootstrap) Write(addr string, buffer []byte) (n int, e error)
- type Context
- type ContextListener
- type DefaultContext
- func (ctx *DefaultContext) Addr() string
- func (ctx *DefaultContext) Close() error
- func (ctx *DefaultContext) Idle() time.Duration
- func (ctx *DefaultContext) IsClosed() bool
- func (ctx *DefaultContext) LocalAddr() net.Addr
- func (ctx *DefaultContext) Read(b []byte) (n int, e error)
- func (ctx *DefaultContext) RemoteAddr() net.Addr
- func (ctx *DefaultContext) ToString() string
- func (ctx *DefaultContext) Write(b []byte) (n int, e error)
- func (ctx *DefaultContext) WriteSerialObject(s Serializable) (n int, e error)
- type Handler
- type Options
- type Serializable
Constants ¶
View Source
const ( // VERSION is the current version. VERSION = "1.0.0" // ACCEPT_MIN_SLEEP is the minimum acceptable sleep times on temporary errors. ACCEPT_MIN_SLEEP = 10 * time.Millisecond // ACCEPT_MAX_SLEEP is the maximum acceptable sleep times on temporary errors ACCEPT_MAX_SLEEP = 1 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bootstrap ¶
type Bootstrap struct {
// contains filtered or unexported fields
}
Bootstrap 启动器
func (*Bootstrap) ConnectJoinAddr ¶
Connect 使用指定地址、端口的连接字符串连接
func (*Bootstrap) ConnectJoinAddrAndReturn ¶
Connect 使用指定地址、端口的连接字符串进行连接并返回连接
func (*Bootstrap) Debug ¶
func (bootstrap *Bootstrap) Debug(v ...interface{})
Debug logs a debug statement
func (*Bootstrap) Disconnect ¶
Disconnect 关闭指定连接
func (*Bootstrap) Fatal ¶
func (bootstrap *Bootstrap) Fatal(v ...interface{})
Fatal logs a fatal error
func (*Bootstrap) HasConnect ¶
HasConnect find connect by addr, return bool
func (*Bootstrap) NewRandomConnect ¶
NewRandomConnect 连接指定本地和远程地址、端口(laddr端口为0为随机端口)。特殊业务使用
func (*Bootstrap) Notice ¶
func (bootstrap *Bootstrap) Notice(v ...interface{})
Notice logs a notice statement
func (*Bootstrap) RegisterContextListener ¶
func (bootstrap *Bootstrap) RegisterContextListener(contextListener ContextListener) *Bootstrap
RegisterContextListener 注册连接的监听接口
func (*Bootstrap) RegisterHandler ¶
RegisterHandler 注册连接接收数据时回调执行函数
func (*Bootstrap) SetKeepAlive ¶
SetKeepAlive 配置连接keepalive,default is false
func (*Bootstrap) Trace ¶
func (bootstrap *Bootstrap) Trace(v ...interface{})
Trace logs a trace statement
type Context ¶
type Context interface { Read(b []byte) (n int, err error) Write(b []byte) (n int, err error) WriteSerialObject(s Serializable) (n int, e error) LocalAddr() net.Addr RemoteAddr() net.Addr Close() error IsClosed() bool Idle() time.Duration Addr() string ToString() string }
Context the context of connection, like conn channel, not go chan.
type ContextListener ¶
type DefaultContext ¶
type DefaultContext struct {
// contains filtered or unexported fields
}
DefaultContext default context
func (*DefaultContext) RemoteAddr ¶
func (ctx *DefaultContext) RemoteAddr() net.Addr
RemoteAddr 远程连接地址
func (*DefaultContext) ToString ¶
func (ctx *DefaultContext) ToString() string
ToString 打印net.Conn的基本参数
func (*DefaultContext) Write ¶
func (ctx *DefaultContext) Write(b []byte) (n int, e error)
Write 写数据
func (*DefaultContext) WriteSerialObject ¶
func (ctx *DefaultContext) WriteSerialObject(s Serializable) (n int, e error)
WriteSerialObject 写序列化数据
type Serializable ¶
type Serializable interface {
Bytes() []byte
}
Click to show internal directories.
Click to hide internal directories.