iface

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IMessage

type IMessage interface {
	GetBizType() string //获取消息业务类型
	GetContent() string //获取消息内容
	GetMsgId() uint32   //获取消息ID
	GetParam() map[string]interface{}

	SetBizType(string) //设置消息业务类型
	SetContent(string) //设置消息内容
	SetMsgId(uint32)   //设置消息ID
	SetParam(param map[string]interface{})
}

type IMsgHandle

type IMsgHandle interface {
	DoMsgHandler(request IMessage, workerID int) //马上以非阻塞方式处理消息
	AddRouter(bizType string, router IRouter)    //为消息添加具体的处理逻辑
	StartWorkerPool()                            //启动worker工作池
	SendMsgToTaskQueue(request IMessage)         //将消息交给TaskQueue,由worker进行处理
	StartOneWorker(workerID int, taskQueue chan IMessage)
	Stop()
	Stat() []atomic2.Int64
}

消息管理抽象层

type IRouter

type IRouter interface {
	Handle(request IMessage) (ack bool) //处理conn业务的方法
	DeadHandle(request IMessage)        //处理失败的
	DbHandle(request IMessage)          //处理DB业务
}

type IServer

type IServer interface {
	//启动服务器方法
	Start()
	//停止服务器方法
	Stop()
	//开启业务服务方法
	Serve()
	//路由功能:给当前服务注册一个路由业务方法,供客户端链接处理使用
	AddRouter(bizType string, router IRouter)

	AddMessage(msg IMessage) //添加消息

	Stat() []atomic2.Int64 //获取进程处理的数量
}

定义服务器接口

Jump to

Keyboard shortcuts

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