middleware

package
v0.0.0-...-f53f79a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2019 License: MIT, GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelManager

type ChannelManager interface {
	// 初始化通道管理器。
	// 参数channelArgs代表通道参数的容器。
	// 参数reset指明是否重新初始化通道管理器。
	Init(channelArgs base.ChannelArgs, reset bool) bool
	// 关闭通道管理器。
	Close() bool
	// 获取请求传输通道。
	ReqChan() (chan base.Request, error)
	// 获取响应传输通道。
	RespChan() (chan base.Response, error)
	// 获取条目传输通道。
	ItemChan() (chan base.Item, error)
	// 获取错误传输通道。
	ErrorChan() (chan error, error)
	// 获取通道管理器的状态。
	Status() ChannelManagerStatus
	// 获取摘要信息。
	Summary() string
}

通道管理器的接口类型。

func NewChannelManager

func NewChannelManager(channelArgs base.ChannelArgs) ChannelManager

创建通道管理器。

type ChannelManagerStatus

type ChannelManagerStatus uint8

被用来表示通道管理器的状态的类型。

const (
	CHANNEL_MANAGER_STATUS_UNINITIALIZED ChannelManagerStatus = 0 // 未初始化状态。
	CHANNEL_MANAGER_STATUS_INITIALIZED   ChannelManagerStatus = 1 // 已初始化状态。
	CHANNEL_MANAGER_STATUS_CLOSED        ChannelManagerStatus = 2 // 已关闭状态。
)

type Entity

type Entity interface {
	Id() uint32 // ID的获取方法。
}

实体的接口类型。

type IdGenerator

type IdGenerator interface {
	GetUint32() uint32 // 获得一个uint32类型的ID。
}

ID生成器的接口类型。

func NewIdGenerator

func NewIdGenerator() IdGenerator

创建ID生成器。

type IdGenerator2

type IdGenerator2 interface {
	GetUint64() uint64 // 获得一个uint64类型的ID。
}

ID生成器的接口类型2。

func NewIdGenerator2

func NewIdGenerator2() IdGenerator2

创建ID生成器2。

type Pool

type Pool interface {
	Take() (Entity, error)      // 取出实体
	Return(entity Entity) error // 归还实体。
	Total() uint32              // 实体池的容量。
	Used() uint32               // 实体池中已被使用的实体的数量。
}

实体池的接口类型。

func NewPool

func NewPool(
	total uint32,
	entityType reflect.Type,
	genEntity func() Entity) (Pool, error)

创建实体池。

type StopSign

type StopSign interface {
	// 置位停止信号。相当于发出停止信号。
	// 如果先前已发出过停止信号,那么该方法会返回false。
	Sign() bool
	// 判断停止信号是否已被发出。
	Signed() bool
	// 重置停止信号。相当于收回停止信号,并清除所有的停止信号处理记录。
	Reset()
	// 处理停止信号。
	// 参数code应该代表停止信号处理方的代号。该代号会出现在停止信号的处理记录中。
	Deal(code string)
	// 获取某一个停止信号处理方的处理计数。该处理计数会从相应的停止信号处理记录中获得。
	DealCount(code string) uint32
	// 获取停止信号被处理的总计数。
	DealTotal() uint32
	// 获取摘要信息。其中应该包含所有的停止信号处理记录。
	Summary() string
}

停止信号的接口类型。

func NewStopSign

func NewStopSign() StopSign

创建停止信号。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL