Documentation ¶
Index ¶
- func ConnHuixie(conn *net.TCPConn, msg []byte, v int) error
- func NewConnManager() Miface.IConnManager
- func NewConnect(server Miface.MServer, getconn *net.TCPConn, getconnID int64, ...) Miface.Iconnect
- func NewMessage(sendID uint64, sendData []byte) Miface.Imessage
- func NewMsgHandle() Miface.IMsgHandle
- func NewServer(ip string, port int) Miface.MServer
- type BaseRouter
- type ConnManager
- type Connect
- func (c *Connect) GetConnID() int64
- func (c *Connect) Getconn() *net.TCPConn
- func (c *Connect) GetconnInfo() net.Addr
- func (c *Connect) InfoAdd(infoIn string, a interface{})
- func (c *Connect) InfoDel(infoIn string)
- func (c *Connect) InfoFind(infoIn string) interface{}
- func (c *Connect) SendMsg(msg []byte) error
- func (c *Connect) SendPackMsg(sendID uint64, sendData []byte) error
- func (c *Connect) Start()
- func (c *Connect) StartReader()
- func (c *Connect) StartWriter()
- func (c *Connect) Stop()
- type Message
- type MsgHandle
- type Pack
- type Request
- type Server
- func (s *Server) AddNewRouter(addid uint64, router Miface.IRouter)
- func (s *Server) GetServerConnManager() Miface.IConnManager
- func (s *Server) Run()
- func (s *Server) ServerChannelListen()
- func (s *Server) ServerDoOpen(getcon net.Conn)
- func (s *Server) ServerDoSomething(getcon net.Conn)
- func (s *Server) ServerGetConn()
- func (s *Server) Start()
- func (s *Server) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnManager ¶
type ConnManager struct { ConnPoolMap map[int]Miface.Iconnect // contains filtered or unexported fields }
用于实现控制连接connManager的接口
connManager所需的结构体
func (*ConnManager) ConnManAdd ¶
func (cm *ConnManager) ConnManAdd(connIn Miface.Iconnect) error
增加连接
func (*ConnManager) ConnManGetID ¶
func (cm *ConnManager) ConnManGetID(idIn int) Miface.Iconnect
根据连接ID获取连接
type Connect ¶
type Connect struct { // 连接所属服务器 ConnServer Miface.MServer // 连接句柄 Conn *net.TCPConn // 连接ID ConnID int64 // 连接状态 Isclosed bool // 连接绑定的方法 ConnAPI Miface.BangdinFunc // 检查当前连接是否已经终止的管道 CheakExitC chan bool // 添加一个router // Router Miface.IRouter // 将之前的router单路由控制模式 转换成使用路由管理MsgHandle来控制 实现多路由管理 CMsgHandle Miface.IMsgHandle // 创建一个给写进程发送数据的管道 CtransData chan []byte // contains filtered or unexported fields }
func (*Connect) SendPackMsg ¶
提供一个发送封装好的Message数据包的方法
type MsgHandle ¶
type MsgHandle struct { // 使用map来存放所有的message所对应使用router路由方法 MsgHandleMap map[uint64]Miface.IRouter // 定义一组消息队列 因为是一组 所以使用切片 MsgHandleDuilie []chan Miface.Irequest // 定义工作池的工作单元个数 MsgHandleWorkUnitNum int }
用于实现msgHandle的接口
func (*MsgHandle) SendRequestToWorkPool ¶
将收到的request发送给对应的工作池 并做简易负载均衡
func (*MsgHandle) StartWorkUnit ¶
工作单元go程 接收传来的工作request请求 与工作单元id 并调用MsgHandle的调度路由方法来使用request
type Server ¶
type Server struct { Name string IpVer string Ip string Channel chan string ChannelStop chan bool // Router Miface.IRouter MsgHandle Miface.IMsgHandle // 连接控制队列 ConnManager Miface.IConnManager // contains filtered or unexported fields }
定义结构
func (*Server) AddNewRouter ¶
新增router的方法
func (*Server) GetServerConnManager ¶
func (s *Server) GetServerConnManager() Miface.IConnManager
返回服务器所拥有的连接池
func (*Server) ServerDoOpen ¶
连接创建成功后的进行 阻塞 检测停止 并运行相应命令
Click to show internal directories.
Click to hide internal directories.