Documentation
¶
Index ¶
- Constants
- Variables
- func IsServerStopping() bool
- func SetServerStopping()
- type IServer
- type Server
- type ServerOptions
- func (p *ServerOptions) WithETCDCallbackFun(callbackFun xetcd.CallbackFun) *ServerOptions
- func (p *ServerOptions) WithKCPHandler(handler xnetcommon.IHandler) *ServerOptions
- func (p *ServerOptions) WithLogCallbackFunc(callbackFunc xlog.CallBackFunc) *ServerOptions
- func (p *ServerOptions) WithTCPHandler(handler xnetcommon.IHandler) *ServerOptions
Constants ¶
View Source
const ReportIntervalSecondDefault int64 = 30 // etcd-上报时间间隔 秒
View Source
const (
ServerInfoTimeOutSec int64 = 60 // 信息-打印 超时时间 秒
)
View Source
const StatusRunning = 0 // 服务状态:运行中
View Source
const StatusStopping = 1 // 服务状态:关闭中
Variables ¶
View Source
var GBusChannelQuitCheck = make(chan struct{}, 1)
总线-channel-退出检查
View Source
var GServerStatus uint32
Functions ¶
Types ¶
type Server ¶
type Server struct { ConfigMgr xconfig.Mgr ConfigSub *xconfig.Sub GroupID uint32 // 组ID Name string // 名称 ID uint32 // ID ExecutablePath string // 执行程序路径 // 程序所在路径(如为link,则为link所在的路径) AvailableLoad uint32 // 可用负载 Log xlog.ILog TimeMgr *xtime.Mgr Timer xtimer.ITimer Etcd xetcd.IEtcd EtcdKey string // etcd key BusChannel chan interface{} // 总线 BusChannelWaitGroup sync.WaitGroup // 总线等待 QuitChan chan struct{} // 退出信号, 用于关闭服务 TCPServer *xnettcp.Server KCPServer *xnetkcp.Server ServerObject IServer // 服务实例 // contains filtered or unexported fields }
func (*Server) Handle ¶
Handle todo [重要] issue 在处理 event 时候, 向 eventChan 中插入 事件,注意超出eventChan的上限会阻塞. 目前有超时机制来防止阻塞.
type ServerOptions ¶
type ServerOptions struct { TCPHandler xnetcommon.IHandler KCPHandler xnetcommon.IHandler LogCallbackFunc xlog.CallBackFunc ETCDCallbackFun xetcd.CallbackFun }
ServerOptions contains options to configure a Server instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*ServerOptions) WithETCDCallbackFun ¶
func (p *ServerOptions) WithETCDCallbackFun(callbackFun xetcd.CallbackFun) *ServerOptions
func (*ServerOptions) WithKCPHandler ¶
func (p *ServerOptions) WithKCPHandler(handler xnetcommon.IHandler) *ServerOptions
func (*ServerOptions) WithLogCallbackFunc ¶
func (p *ServerOptions) WithLogCallbackFunc(callbackFunc xlog.CallBackFunc) *ServerOptions
func (*ServerOptions) WithTCPHandler ¶
func (p *ServerOptions) WithTCPHandler(handler xnetcommon.IHandler) *ServerOptions
Click to show internal directories.
Click to hide internal directories.