Documentation
¶
Index ¶
- Constants
- Variables
- type Acceptor
- type AcceptorNewConnectionCallback
- type Buffer
- func (b *Buffer) Append(data []byte)
- func (b *Buffer) Peek() *byte
- func (b *Buffer) Prepend(data []byte)
- func (b *Buffer) PrependBytes() int
- func (b *Buffer) ReadFd(fd int, saveErrno *error) int
- func (b *Buffer) ReadableBytes() int
- func (b *Buffer) Retrieve(size int)
- func (b *Buffer) RetrieveAll()
- func (b *Buffer) RetrieveAllString() []byte
- func (b *Buffer) RetrieveAsString(size int) []byte
- func (b *Buffer) WriteableBytes() int
- type Channel
- func (c *Channel) DisableAll()
- func (c *Channel) DisableReading()
- func (c *Channel) DisableWriting()
- func (c *Channel) EnableReading()
- func (c *Channel) EnableWriting()
- func (c *Channel) Events() int16
- func (c *Channel) Fd() int32
- func (c *Channel) HandleEvent(time time.Time)
- func (c *Channel) Index() int
- func (c *Channel) IsNoneEvent() bool
- func (c *Channel) IsReading() bool
- func (c *Channel) IsWriting() bool
- func (c *Channel) OwnerLoop() *EventLoop
- func (c *Channel) Remove()
- func (c *Channel) SetCloseCallback(cb EventCallback)
- func (c *Channel) SetErrorCallback(cb EventCallback)
- func (c *Channel) SetIndex(idx int)
- func (c *Channel) SetReadCallback(cb ReadEventCallback)
- func (c *Channel) SetRevents(revt int16)
- func (c *Channel) SetWriteCallback(cb EventCallback)
- type CloseCallback
- type ConnectionCallback
- type Connector
- type ConnectorNewConnectionCallback
- type EpollPoller
- type EventCallback
- type EventLoop
- func (loop *EventLoop) AssertInLoopGoroutine()
- func (loop *EventLoop) Cancel(timerid TimerId)
- func (loop *EventLoop) DoPendingFunctors()
- func (loop *EventLoop) HandleRead(t time.Time)
- func (loop *EventLoop) IsInLoopGoroutine() bool
- func (loop *EventLoop) Loop()
- func (loop *EventLoop) QueueInLoop(cb Functor)
- func (loop *EventLoop) Quit()
- func (loop *EventLoop) RemoveChannel(c *Channel)
- func (loop *EventLoop) RunAfter(duration time.Duration, cb TimerCallback) TimerId
- func (loop *EventLoop) RunAt(t time.Time, cb TimerCallback) TimerId
- func (loop *EventLoop) RunEvery(interval float64, cb TimerCallback) TimerId
- func (loop *EventLoop) RunInLoop(cb Functor)
- func (loop *EventLoop) UpdateChannel(c *Channel)
- func (loop *EventLoop) Wakeup()
- type EventLoopGoroutine
- type EventLoopGoroutinePool
- type Functor
- type GoroutineCallback
- type HighWaterMarkCallback
- type Log
- type MessageCallback
- type PollPoller
- type Poller
- type ReadEventCallback
- type TcpClient
- func (tc *TcpClient) Connect()
- func (tc *TcpClient) Disconnect()
- func (tc *TcpClient) EnableRetry()
- func (tc *TcpClient) GetLoop() *EventLoop
- func (tc *TcpClient) IsRetry() bool
- func (tc *TcpClient) Name() string
- func (tc *TcpClient) SetConnectionCallback(cb ConnectionCallback)
- func (tc *TcpClient) SetMessageCallback(cb MessageCallback)
- func (tc *TcpClient) SetWriteCompleteCallback(cb WriteCompleteCallback)
- func (tc *TcpClient) Stop()
- type TcpConnection
- func (tc *TcpConnection) BindWriteCompleteCallback() func()
- func (tc *TcpConnection) ConnectDestroyed()
- func (tc *TcpConnection) ConnectEstablished()
- func (tc *TcpConnection) Connected() bool
- func (tc *TcpConnection) ForceClose()
- func (tc *TcpConnection) GetLoop() *EventLoop
- func (tc *TcpConnection) InBuffer() *Buffer
- func (tc *TcpConnection) LocalAddr() *netip.AddrPort
- func (tc *TcpConnection) Name() string
- func (tc *TcpConnection) OutBuffer() *Buffer
- func (tc *TcpConnection) PeerAddr() *netip.AddrPort
- func (tc *TcpConnection) Send(message []byte)
- func (tc *TcpConnection) SendFromBuffer(buf *Buffer)
- func (tc *TcpConnection) SetCloseCallback(cb CloseCallback)
- func (tc *TcpConnection) SetConnectionCallback(cb ConnectionCallback)
- func (tc *TcpConnection) SetHighWaterMarkCallback(cb HighWaterMarkCallback)
- func (tc *TcpConnection) SetMessageCallback(cb MessageCallback)
- func (tc *TcpConnection) SetTcpNoDelay(on bool)
- func (tc *TcpConnection) SetWriteCompleteCallback(cb WriteCompleteCallback)
- func (tc *TcpConnection) Shutdown()
- type TcpServer
- func (t *TcpServer) SetConnectionCallback(cb ConnectionCallback)
- func (t *TcpServer) SetGoroutineCallback(cb GoroutineCallback)
- func (t *TcpServer) SetGoroutineNum(num int)
- func (t *TcpServer) SetMessageCallback(cb MessageCallback)
- func (t *TcpServer) SetWriteCompleteCallback(cb WriteCompleteCallback)
- func (t *TcpServer) Start()
- type TimeEntry
- type Timer
- type TimerCallback
- type TimerId
- type TimerList
- type TimerQueue
- type WriteCompleteCallback
Constants ¶
View Source
const ( PrependSize = 8 BufferInitSize = 1024 )
View Source
const ( MaxRetryTime = 30 * time.Second InitRetryTime = 500 * time.Millisecond )
View Source
const (
InitEventListSize = 16
)
Variables ¶
View Source
var AtomicNumber int64 = 0
View Source
var Dlog = &Log{ IsOpenDebugLog: false, }
Functions ¶
This section is empty.
Types ¶
type Acceptor ¶
type Acceptor struct {
// contains filtered or unexported fields
}
func NewAcceptor ¶
func (*Acceptor) SetAcceptorNewConnectionCallback ¶
func (a *Acceptor) SetAcceptorNewConnectionCallback(cb AcceptorNewConnectionCallback)
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func (*Buffer) PrependBytes ¶
func (*Buffer) ReadableBytes ¶
func (*Buffer) RetrieveAll ¶
func (b *Buffer) RetrieveAll()
func (*Buffer) RetrieveAllString ¶
func (*Buffer) RetrieveAsString ¶
func (*Buffer) WriteableBytes ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func NewChannel ¶
func (*Channel) DisableAll ¶
func (c *Channel) DisableAll()
func (*Channel) DisableReading ¶
func (c *Channel) DisableReading()
func (*Channel) DisableWriting ¶
func (c *Channel) DisableWriting()
func (*Channel) EnableReading ¶
func (c *Channel) EnableReading()
func (*Channel) EnableWriting ¶
func (c *Channel) EnableWriting()
func (*Channel) HandleEvent ¶
func (*Channel) IsNoneEvent ¶
func (*Channel) SetCloseCallback ¶
func (c *Channel) SetCloseCallback(cb EventCallback)
func (*Channel) SetErrorCallback ¶
func (c *Channel) SetErrorCallback(cb EventCallback)
func (*Channel) SetReadCallback ¶
func (c *Channel) SetReadCallback(cb ReadEventCallback)
func (*Channel) SetRevents ¶
func (*Channel) SetWriteCallback ¶
func (c *Channel) SetWriteCallback(cb EventCallback)
type CloseCallback ¶
type CloseCallback func(*TcpConnection)
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
func (*Connector) SetConnectorNewConnectionCallback ¶
func (c *Connector) SetConnectorNewConnectionCallback(cb ConnectorNewConnectionCallback)
type ConnectorNewConnectionCallback ¶
type ConnectorNewConnectionCallback func(int)
type EpollPoller ¶
type EpollPoller struct {
// contains filtered or unexported fields
}
func NewEpollPoller ¶
func NewEpollPoller(loop *EventLoop) (ep *EpollPoller)
func (*EpollPoller) AssertInLoopGoroutine ¶
func (e *EpollPoller) AssertInLoopGoroutine()
func (*EpollPoller) Poll ¶
func (e *EpollPoller) Poll(timeoutMs int, activeChannels *[]*Channel) time.Time
func (*EpollPoller) RemoveChannel ¶
func (e *EpollPoller) RemoveChannel(channel *Channel)
func (*EpollPoller) UpdateChannel ¶
func (e *EpollPoller) UpdateChannel(channel *Channel)
type EventCallback ¶
type EventCallback func()
type EventLoop ¶
type EventLoop struct {
// contains filtered or unexported fields
}
func NewEventLoop ¶
func NewEventLoop() (el *EventLoop)
func (*EventLoop) AssertInLoopGoroutine ¶
func (loop *EventLoop) AssertInLoopGoroutine()
func (*EventLoop) DoPendingFunctors ¶
func (loop *EventLoop) DoPendingFunctors()
execute callback in queue
func (*EventLoop) IsInLoopGoroutine ¶
func (*EventLoop) RemoveChannel ¶
func (*EventLoop) RunAfter ¶
func (loop *EventLoop) RunAfter(duration time.Duration, cb TimerCallback) TimerId
callback run 'delay' from now
func (*EventLoop) RunAt ¶
func (loop *EventLoop) RunAt(t time.Time, cb TimerCallback) TimerId
callback run at 't'
func (*EventLoop) RunEvery ¶
func (loop *EventLoop) RunEvery(interval float64, cb TimerCallback) TimerId
callback run every 'interval'
func (*EventLoop) UpdateChannel ¶
type EventLoopGoroutine ¶
type EventLoopGoroutine struct {
// contains filtered or unexported fields
}
func NewEventLoopGoroutine ¶
func NewEventLoopGoroutine(cb GoroutineCallback) (elg *EventLoopGoroutine)
func (*EventLoopGoroutine) StartLoop ¶
func (elg *EventLoopGoroutine) StartLoop() *EventLoop
type EventLoopGoroutinePool ¶
type EventLoopGoroutinePool struct {
// contains filtered or unexported fields
}
func NewEventLoopGoroutinePool ¶
func NewEventLoopGoroutinePool(baseLoop *EventLoop) *EventLoopGoroutinePool
func (*EventLoopGoroutinePool) GetNextLoop ¶
func (ep *EventLoopGoroutinePool) GetNextLoop() (loop *EventLoop)
func (*EventLoopGoroutinePool) IsStarted ¶
func (ep *EventLoopGoroutinePool) IsStarted() bool
func (*EventLoopGoroutinePool) SetGoroutineNum ¶
func (ep *EventLoopGoroutinePool) SetGoroutineNum(num int)
func (*EventLoopGoroutinePool) Start ¶
func (ep *EventLoopGoroutinePool) Start(cb GoroutineCallback)
type GoroutineCallback ¶
type GoroutineCallback func(*EventLoop)
type HighWaterMarkCallback ¶
type HighWaterMarkCallback func(*TcpConnection, int)
type Log ¶
type Log struct {
IsOpenDebugLog bool
}
func (*Log) TurnOffLog ¶
func (d *Log) TurnOffLog()
type MessageCallback ¶
type MessageCallback func(*TcpConnection, *Buffer, time.Time)
type PollPoller ¶
type PollPoller struct {
// contains filtered or unexported fields
}
func NewPollPoller ¶
func NewPollPoller(loop *EventLoop) *PollPoller
func (*PollPoller) AssertInLoopGoroutine ¶
func (p *PollPoller) AssertInLoopGoroutine()
func (*PollPoller) Poll ¶
func (p *PollPoller) Poll(timeoutMs int, activeChannels *[]*Channel) time.Time
func (*PollPoller) RemoveChannel ¶
func (p *PollPoller) RemoveChannel(channel *Channel)
func (*PollPoller) UpdateChannel ¶
func (p *PollPoller) UpdateChannel(channel *Channel)
type Poller ¶
type Poller interface { Poll(timeoutMs int, activeChannels *[]*Channel) time.Time UpdateChannel(channel *Channel) RemoveChannel(channel *Channel) // contains filtered or unexported methods }
func NewDefaultPoller ¶
type ReadEventCallback ¶
type TcpClient ¶
type TcpClient struct {
// contains filtered or unexported fields
}
func NewTcpClient ¶
func (*TcpClient) Disconnect ¶
func (tc *TcpClient) Disconnect()
func (*TcpClient) EnableRetry ¶
func (tc *TcpClient) EnableRetry()
func (*TcpClient) SetConnectionCallback ¶
func (tc *TcpClient) SetConnectionCallback(cb ConnectionCallback)
func (*TcpClient) SetMessageCallback ¶
func (tc *TcpClient) SetMessageCallback(cb MessageCallback)
func (*TcpClient) SetWriteCompleteCallback ¶
func (tc *TcpClient) SetWriteCompleteCallback(cb WriteCompleteCallback)
type TcpConnection ¶
type TcpConnection struct {
// contains filtered or unexported fields
}
func NewTcpConnection ¶
func NewTcpConnection(loop *EventLoop, name string, fd int, localAddr *netip.AddrPort, peerAddr *netip.AddrPort) (conn *TcpConnection)
************************* public: *************************
func (*TcpConnection) BindWriteCompleteCallback ¶
func (tc *TcpConnection) BindWriteCompleteCallback() func()
func (*TcpConnection) ConnectDestroyed ¶
func (tc *TcpConnection) ConnectDestroyed()
called when TcpServer has removed me from it's map
func (*TcpConnection) ConnectEstablished ¶
func (tc *TcpConnection) ConnectEstablished()
called when TcpServer accepts a new connection
func (*TcpConnection) Connected ¶
func (tc *TcpConnection) Connected() bool
func (*TcpConnection) ForceClose ¶ added in v1.0.1
func (tc *TcpConnection) ForceClose()
ForceClose: force close connetion
func (*TcpConnection) GetLoop ¶
func (tc *TcpConnection) GetLoop() *EventLoop
func (*TcpConnection) InBuffer ¶
func (tc *TcpConnection) InBuffer() *Buffer
func (*TcpConnection) LocalAddr ¶
func (tc *TcpConnection) LocalAddr() *netip.AddrPort
func (*TcpConnection) Name ¶
func (tc *TcpConnection) Name() string
func (*TcpConnection) OutBuffer ¶
func (tc *TcpConnection) OutBuffer() *Buffer
func (*TcpConnection) PeerAddr ¶
func (tc *TcpConnection) PeerAddr() *netip.AddrPort
func (*TcpConnection) SendFromBuffer ¶
func (tc *TcpConnection) SendFromBuffer(buf *Buffer)
send the data from 'buf'
func (*TcpConnection) SetCloseCallback ¶
func (tc *TcpConnection) SetCloseCallback(cb CloseCallback)
func (*TcpConnection) SetConnectionCallback ¶
func (tc *TcpConnection) SetConnectionCallback(cb ConnectionCallback)
set callback
func (*TcpConnection) SetHighWaterMarkCallback ¶
func (tc *TcpConnection) SetHighWaterMarkCallback(cb HighWaterMarkCallback)
func (*TcpConnection) SetMessageCallback ¶
func (tc *TcpConnection) SetMessageCallback(cb MessageCallback)
func (*TcpConnection) SetTcpNoDelay ¶
func (tc *TcpConnection) SetTcpNoDelay(on bool)
func (*TcpConnection) SetWriteCompleteCallback ¶
func (tc *TcpConnection) SetWriteCompleteCallback(cb WriteCompleteCallback)
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewTcpServer ¶
func (*TcpServer) SetConnectionCallback ¶
func (t *TcpServer) SetConnectionCallback(cb ConnectionCallback)
func (*TcpServer) SetGoroutineCallback ¶
func (t *TcpServer) SetGoroutineCallback(cb GoroutineCallback)
func (*TcpServer) SetGoroutineNum ¶
func (*TcpServer) SetMessageCallback ¶
func (t *TcpServer) SetMessageCallback(cb MessageCallback)
func (*TcpServer) SetWriteCompleteCallback ¶
func (t *TcpServer) SetWriteCompleteCallback(cb WriteCompleteCallback)
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
func (*Timer) Expiration ¶
type TimerCallback ¶
type TimerCallback func()
type TimerId ¶
func NewTimerId ¶
type TimerList ¶
type TimerList []TimeEntry
type TimerQueue ¶
type TimerQueue struct {
// contains filtered or unexported fields
}
fix: more high performance
func NewTimerQueue ¶
func NewTimerQueue(loop *EventLoop) (tq *TimerQueue)
func (*TimerQueue) AddTimer ¶
func (tq *TimerQueue) AddTimer(cb TimerCallback, when time.Time, interval float64) TimerId
func (*TimerQueue) Cancel ¶
func (tq *TimerQueue) Cancel(timerid TimerId)
func (*TimerQueue) HandleRead ¶
func (tq *TimerQueue) HandleRead(t time.Time)
called when timer alarms
type WriteCompleteCallback ¶
type WriteCompleteCallback func(*TcpConnection)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.