Documentation
¶
Overview ¶
Copyright 2023-2024 antlabs. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func DebugConns(conns *core.SafeConns[Conn], maxConns int)
- func WithCallback(callback Callback) func(*Options)
- func WithEventLoopReadBufferSize(size int) func(*Options)
- func WithFlowBackPressure(enable bool) func(*Options)
- func WithFlowBackPressureRemoveRead(enable bool) func(*Options)
- func WithLogLevel(level slog.Level) func(*Options)
- func WithMaxSocketReadTimes(maxSocketReadTimes int) func(*Options)
- func WithTaskType(taskType TaskType) func(*Options)
- func WithTriggerType(triggerType core.TriggerType) func(*Options)
- type Callback
- type ClientEventLoop
- type Conn
- func (c *Conn) Close()
- func (c *Conn) GetSession() any
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetNoDelay(nodelay bool) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetSession(session any)
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(data []byte) (int, error)
- type MultiEventLoop
- type OnClose
- type OnData
- type OnOpen
- type Options
- type TaskType
Constants ¶
const TriggerTypeEdge = core.TriggerTypeEdge
边缘触发
const TriggerTypeLevel = core.TriggerTypeLevel
水平触发
Variables ¶
This section is empty.
Functions ¶
func DebugConns ¶
debug 函数,用于打印连接的缓冲区使用情况
func WithEventLoopReadBufferSize ¶
设置event loop里面读buffer的大小
func WithFlowBackPressure ¶
设置流量背压机制,当连接的写缓冲区满了,会暂停读取,直到写缓冲区有空闲空间 目前垂直(et)触发模式下会有问题 如果要在et模式实现流量背压机制,就需要自己管理fd的可读/可写状态, 因为内核只会在 不可读->可读 的时候触发事件, 可读但是未读取的时候不会触发事件 可写同理, 可写->不可写 的时候触发事件, 不可写但是未写入的时候不会触发事件 TODO et模式支持下
func WithFlowBackPressureRemoveRead ¶
设置流量背压机制,当连接的写缓冲区满了,会移除读事件,直到写缓冲区有空闲空间 第二种背压机制会比第一种背压机制更高效(lt模式下,et没有实现), 7945hx cpu上,第二种是3.4GB/s的读写 第一种是3.0GB/s的读写 TODO et模式优化下
func WithMaxSocketReadTimes ¶
单次可读事情,最大读取次数(水平触发模式有效)
func WithTriggerType ¶
func WithTriggerType(triggerType core.TriggerType) func(*Options)
设置水平触发还是边缘触发
Types ¶
type Callback ¶
type ClientEventLoop ¶
type ClientEventLoop struct {
*MultiEventLoop
// contains filtered or unexported fields
}
func NewClientEventLoop ¶
func NewClientEventLoop(ctx context.Context, opts ...func(*Options)) *ClientEventLoop
func (*ClientEventLoop) RegisterConn ¶
func (loop *ClientEventLoop) RegisterConn(conn net.Conn) error
func (*ClientEventLoop) Serve ¶
func (loop *ClientEventLoop) Serve()
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) GetSession ¶
func (*Conn) SetNoDelay ¶
func (*Conn) SetSession ¶
type MultiEventLoop ¶
type MultiEventLoop struct {
// contains filtered or unexported fields
}
func NewMultiEventLoop ¶
func NewMultiEventLoop(ctx context.Context, options ...func(*Options)) (e *MultiEventLoop, err error)
func (*MultiEventLoop) Free ¶
func (e *MultiEventLoop) Free()
func (*MultiEventLoop) ListenAndServe ¶
func (e *MultiEventLoop) ListenAndServe(addr string) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
core/client
command
|
|
|
core/server
command
|
|
|
echo/client
command
|
|
|
echo/server
command
|
|
|
flow_backpressure
command
|
|
|
tlv
command
|
|
|
tlv/client
command
|
|
|
tlv/server
command
|