Versions in this module Expand all Collapse all v1 v1.0.5 Nov 23, 2023 v1.0.4 Jul 15, 2023 v1.0.3 Jul 11, 2023 v1.0.2 Jul 4, 2023 v1.0.1 Jun 25, 2023 Changes in this version + const ENV_BETA + const ENV_DEV + const ENV_LIVE + const ENV_TEST + const LAN_CTRL_BACKUP + const LAN_CTRL_CLOSE + const LAN_CTRL_CONSOLE + const LAN_CTRL_DUMP + const LAN_CTRL_FLUSHLOG + const LAN_CTRL_HEALTH + const LAN_CTRL_PAUSE + const LAN_CTRL_PRINT + const LAN_CTRL_RESUME + const LAN_CTRL_ROOT + const LAN_CTRL_STATUS type CslCfg + Addr string + Fetch int + Interval int + Logout int + Ns string + Timeout int type IServer + GetCfg func() *SvrCfg + GetEnv func() string + SetTitle func() string type LanCfg + Cgi string + Ctrl string + Link []string + Msg string + func (this *LanCfg) ID() string + func (this *LanCfg) Resolve() (id string, ip string, port int) type LanClt + Addr string + ID string type Server + Cfg *SvrCfg + func (this *Server) GetCfg() *SvrCfg + func (this *Server) GetEnv() string + func (this *Server) SetTitle() string type SvrCfg + Csl *CslCfg + Lan *LanCfg + Log map[string]*xlog.LogCfg + Mysql map[string]*xorm.MysqlCfg + Redis *xorm.RedisCfg + var GCfg *SvrCfg v1.0.0 Jun 11, 2023 Changes in this version + const CONSUL_CHECK_PATH + const CONSUL_RESP_OK + const EVT_SERVER_CHANGED + const EVT_SERVER_PREQUIT + const EVT_SERVER_STARTED + const LAN_CIN_MAX_FRAME + const LAN_COUT_MAX_FRAME + const SERVER_SLEEP + const UPDATE_SLEEP + var CGIROUTEMAP map[int]*CgiRoute + var CslCfg *consulapi.Config + var CslClt *consulapi.Client + var ERR_CGI_INTERRUPTED = errors.New("cgi call has been interrupted, see log context for more details.") + var ERR_CGI_TIMEOUT = errors.New("cgi call timeout") + var ERR_NO_ROUTE_FOUND = errors.New("no route found") + var ERR_RPC_INTERRUPTED = errors.New("rpc call has been interrupted, see log context for more details.") + var ERR_RPC_TIMEOUT = errors.New("rpc call timeout") + var ERR_SEND_CHAN_FULL = errors.New("send chan is full") + var GCgi = xevt.NewEvtMgr(false) + var GEvt = xevt.NewEvtMgr(true) + var GMsg = xevt.NewEvtMgr(true) + var GRpc = xevt.NewEvtMgr(false) + var GServer IServer + var GWrap *Wrap + var MSGROUTEMAP map[int]*MsgRoute + var MainTID int64 = -1 + var RPCROUTEMAP map[int]*RpcRoute + func BackupLan() int + func ClearInterval(id int, tid ...int64) + func ClearTimeout(id int, tid ...int64) + func CloseLan() + func MonitorLan() + func NotifyCgi(id int, creq *xproto.CgiReq, cresp *xproto.CgiResp) bool + func NotifyEvt(id int, param interface{}) bool + func NotifyMsg(id int, mreq *xproto.MsgReq) bool + func NotifyRpc(id int, rreq *xproto.RpcReq, rresp *xproto.RpcResp) bool + func PauseLan() + func PostKV(key string, value string, version string, block ...bool) bool + func PullKV(key string) []byte + func RecvLan() + func RegCgi(id int, fun func(creq *xproto.CgiReq, cresp *xproto.CgiResp)) int + func RegCgiRoute(_map map[int]*CgiRoute) + func RegEvt(id int, fun func(interface{})) int + func RegMsg(id int, fun func(*xproto.MsgReq)) int + func RegMsgRoute(_map map[int]*MsgRoute) + func RegRpc(id int, fun func(rreq *xproto.RpcReq, rresp *xproto.RpcResp)) int + func RegRpcRoute(_map map[int]*RpcRoute) + func RestoreLan() + func ResumeLan() + func RunIn(tid int64, fun func()) chan bool + func RunInMain(fun func()) chan bool + func SendAsync(id int, uid int, req proto.Message, addr string, ...) + func SendCgi(id int, uid int, req *http.Request, addr string, timeout ...int) (cresp *xproto.CgiResp, err error) + func SendFrame(frame xproto.IFrame) bool + func SendMsg(id int, msg proto.Message, mreq *xproto.MsgReq) bool + func SendSync(id int, uid int, req proto.Message, resp proto.Message, addr string, ...) error + func Start(server IServer) + func StartLan(lanCfg *LanCfg, handleMsg func(*xproto.MsgReq), ...) + func Stop() + func SubKV(key string, interval int, onUpdate func(data []byte)) + func UnregCgi(id int, hid int) bool + func UnregEvt(id int, hid int) bool + func UnregMsg(id int, hid int) bool + func UnregRpc(id int, hid int) bool + func WatchSignal() <-chan string + type CgiFunc func(req *xproto.CgiReq, resp *xproto.CgiResp) + func (this CgiFunc) Handle(reply *xevt.EvtReply, req interface{}, resp interface{}) + type CgiRoute struct + Method []string + Timeout int + type EvtFunc func(interface{}) + func (this EvtFunc) Handle(reply *xevt.EvtReply, param1 interface{}, param2 interface{}) + type IServer interface + Destroy func() + GetConfig func() *SvrCfg + GetFPS func() int + GetTitle func() string + Init func() bool + InitConfig func() bool + Name func() string + PreQuit func() + RecvCgi func(creq *xproto.CgiReq, cresp *xproto.CgiResp) + RecvMsg func(mreq *xproto.MsgReq) + RecvRpc func(rreq *xproto.RpcReq, rresp *xproto.RpcResp) + Start func() + Update func(delta float32) + UpdateTitle func() string + type LanCfg struct + Addr string + CgiProto string + GO int + IP string + MaxRx int + MsgProto string + Name string + Port int + Raw string + func NewLanCfg(name, addr string) *LanCfg + func (this *LanCfg) ServerID() string + type LanClt struct + Sockets []mangos.Socket + func NewLanClt(cfg *LanCfg) *LanClt + func (this *LanClt) Close() + func (this *LanClt) Send(bytes []byte, idx int) error + type LanSvr struct + ClientID sync.Map + Clients sync.Map + SClosed bool + var GLan *LanSvr + var GProc []*Proc + func NewLanSvr(cfg *LanCfg) *LanSvr + func (this *LanSvr) Close() + func (this *LanSvr) Recv() ([]byte, error) + func (this *LanSvr) SelectAll(svr string) []*LanClt + func (this *LanSvr) SelectRand(svr string) *LanClt + func (this *LanSvr) SendData(svr string, bytes []byte, idx int) error + func (this *LanSvr) Update(smap map[string][]string) + type MsgFunc func(*xproto.MsgReq) + func (this MsgFunc) Handle(reply *xevt.EvtReply, param1 interface{}, param2 interface{}) + type MsgRoute struct + type Proc struct + CIN chan xproto.IFrame + COUT chan xproto.IFrame + Loop bool + Num int + Pause bool + Resp sync.Map + TID int64 + func NewProc() *Proc + func (this *Proc) MaxID() int64 + func (this *Proc) PopCIN() (xproto.IFrame, bool) + func (this *Proc) PushCIN(frame xproto.IFrame) bool + type Route struct + Dst []string + GoL int + GoR int + ID int + Log int + Name string + RW bool + func (this *Route) GetLog() int + type RpcFunc func(rreq *xproto.RpcReq, rresp *xproto.RpcResp) + func (this RpcFunc) Handle(reply *xevt.EvtReply, param1 interface{}, param2 interface{}) + type RpcRoute struct + type Server struct + Config *SvrCfg + FPS int + REAL IServer + Title string + func (_this *Server) Init() bool + func (_this *Server) PreQuit() + func (this *Server) CTOR(CHILD interface{}) + func (this *Server) Destroy() + func (this *Server) GetConfig() *SvrCfg + func (this *Server) GetFPS() int + func (this *Server) GetTitle() string + func (this *Server) InitConfig() bool + func (this *Server) Name() string + func (this *Server) RecvCgi(rreq *xproto.CgiReq, rresp *xproto.CgiResp) + func (this *Server) RecvMsg(mreq *xproto.MsgReq) + func (this *Server) RecvRpc(rreq *xproto.RpcReq, rresp *xproto.RpcResp) + func (this *Server) Start() + func (this *Server) Update(delta float32) + func (this *Server) UpdateTitle() string + type SvrCfg struct + ConsulAddr string + ConsulDeregister string + ConsulHttp string + ConsulInterval string + ConsulTimeout string + Env string + LanCfg *LanCfg + LinkServer string + Raw xconfig.Configer + func (this *SvrCfg) Init(config string) bool + func (this *SvrCfg) IsDebug() bool + func (this *SvrCfg) SvrID() string + func (this *SvrCfg) SvrName() string + type TimerEntity struct + Crash bool + Func func() + ID int + Log int + RW bool + RawTime int + Repeat bool + Tag interface{} + Time int + func RunInNext(fun func()) *TimerEntity + func SetInterval(fun func(), interval float32, tid ...int64) *TimerEntity + func SetTimeout(fun func(), timeout float32, tid ...int64) *TimerEntity + func (this *TimerEntity) SetLog(log int) *TimerEntity + func (this *TimerEntity) SetRW(sig bool) *TimerEntity + func (this *TimerEntity) SetTag(tag interface{}) *TimerEntity + type TimerRecord struct + LastTime int + TimerID int64 + Timers sync.Map + func (this *TimerRecord) MaxID() int64 + type Wrap struct + ChQuit chan bool + Svr IServer + func NewWrap(server IServer) *Wrap + func (this *Wrap) Destroy() + func (this *Wrap) Init() bool + func (this *Wrap) Run() + func (this *Wrap) Stop()