Versions in this module Expand all Collapse all v0 v0.0.1 Mar 12, 2024 Changes in this version + const DefConnCap + const HdFail + const HdHeartbeat + const HdNotify + const HdOk + const HdPush + const HdRequest + const HdWatch + const HeadCode + const HeadId + const HeadSndId + const HeadSndTs + const HeadSvc + var GenHead util.FnM = func(m util.M) + var Heartbeat = []byte + var MaxReconnect = 5 + var MaxSendRetry = uint8(3) + var ResponseTimeoutDur = time.Duration(5000) * time.Millisecond + var SendRetryDur = time.Second + func ActivePrcNtc[Ntc util.IMsg](pkt kiwi.IRcvNotice, key string, handler func(kiwi.IRcvNotice, Ntc)) + func ActivePrcPus[Pus util.IMsg](pkt kiwi.IRcvPush, key string, handler func(kiwi.IRcvPush, Pus)) + func ActivePrcReq[Req, Res util.IMsg](pkt kiwi.IRcvRequest, key string, handler func(kiwi.IRcvRequest, Req, Res)) + func AsyncReq(pid int64, head util.M, msg util.IMsg, onFail util.FnInt64MUint16, ...) + func AsyncReqBytes(pid int64, svc kiwi.TSvc, code kiwi.TCode, head util.M, json bool, ...) + func AsyncReqNode(pid, nodeId int64, head util.M, msg util.IMsg, onFail util.FnInt64MUint16, ...) + func AsyncReqNodeBytes(pid, nodeId int64, svc kiwi.TSvc, code kiwi.TCode, head util.M, json bool, ...) + func AsyncSubReq[ResT util.IMsg](pkt kiwi.IRcvRequest, head util.M, req util.IMsg, resFail util.FnInt64MUint16, ...) + func BindMsgToSvcCode(msg util.IMsg, svc kiwi.TSvc, code kiwi.TCode) + func CompletePktCount() uint64 + func ExcludeLog(svc kiwi.TSvc, codes ...kiwi.TCode) + func GetService(svc kiwi.TSvc) (kiwi.IService, bool) + func GlobalPrcNtc[Ntc util.IMsg](pkt kiwi.IRcvNotice, handler func(kiwi.IRcvNotice, Ntc)) + func GlobalPrcPus[Pus util.IMsg](pkt kiwi.IRcvPush, handler func(kiwi.IRcvPush, Pus)) + func GlobalPrcReq[Req, Res util.IMsg](pkt kiwi.IRcvRequest, handler func(kiwi.IRcvRequest, Req, Res)) + func GoPrcNtc[Ntc util.IMsg](pkt kiwi.IRcvNotice, handler func(kiwi.IRcvNotice, Ntc)) + func GoPrcPus[Pus util.IMsg](pkt kiwi.IRcvPush, handler func(kiwi.IRcvPush, Pus)) + func GoPrcReq[Req, Res util.IMsg](pkt kiwi.IRcvRequest, handler func(kiwi.IRcvRequest, Req, Res)) + func InitCodec() + func InitGate(receiver kiwi.FnAgentBytes, opts ...GateOption) + func InitNodeLocal() + func InitNodeNet(opts ...NodeOption) + func InitNodeTest() + func InitPacker() + func InitRouter() + func IsExcludeLog(svc kiwi.TSvc, code kiwi.TCode) bool + func MsgToSvcCode(msg util.IMsg) (svc kiwi.TSvc, code kiwi.TCode, ok bool) + func NewNodeLocal() kiwi.INode + func NewNodeNet(opts ...NodeOption) kiwi.INode + func Ntf(pid int64, head util.M, msg util.IMsg) int64 + func Pus(pid int64, head util.M, msg util.IMsg) int64 + func PusNode(pid, nodeId int64, head util.M, msg util.IMsg) int64 + func ReceivePktCount() uint64 + func RegisterSvc(services ...kiwi.IService) + func Req2(pid int64, head util.M, msg util.IMsg) (util.IMsg, util.M, uint16) + func ReqBytes(pid int64, svc kiwi.TSvc, code kiwi.TCode, head util.M, json bool, ...) ([]byte, util.M, uint16) + func ReqNodeBytes(nodeId, pid int64, svc kiwi.TSvc, code kiwi.TCode, head util.M, json bool, ...) ([]byte, util.M, uint16) + func ReqNode[ResT any](nodeId, pid int64, head util.M, msg util.IMsg) (ResT, util.M, uint16) + func Req[ResT util.IMsg](pid int64, head util.M, msg util.IMsg) (ResT, util.M, uint16) + func ResponseSendFailCount() uint64 + func SelfPrcNtc[Ntc util.IMsg](pkt kiwi.IRcvNotice, handler func(kiwi.IRcvNotice, Ntc)) + func SelfPrcPus[Pus util.IMsg](pkt kiwi.IRcvPush, handler func(kiwi.IRcvPush, Pus)) + func SelfPrcReq[Req, Res util.IMsg](pkt kiwi.IRcvRequest, handler func(kiwi.IRcvRequest, Req, Res)) + func SharePrcNtc[Ntc util.IMsg](pkt kiwi.IRcvNotice, key string, handler func(kiwi.IRcvNotice, Ntc)) + func SharePrcPus[Pus util.IMsg](pkt kiwi.IRcvPush, key string, handler func(kiwi.IRcvPush, Pus)) + func SharePrcReq[Req, Res util.IMsg](pkt kiwi.IRcvRequest, key string, handler func(kiwi.IRcvRequest, Req, Res)) + func ShutdownAllService() + func StartAllService() + func StartDefault(opts ...Option) + type Gate struct + type GateOption func(option *gateOption) + func GateCheckIp(fn util.StrToBool) GateOption + func GateConnCap(cap int32) GateOption + func GateConnected(connected kiwi.FnAgent) GateOption + func GateDeadlineSecs(deadline int) GateOption + func GateDisconnected(disconnected kiwi.FnAgentErr) GateOption + func GateHeadLen(headLen uint32) GateOption + func GateIp(ip string) GateOption + func GateRoles(roles map[kiwi.TSvcCode][]int64) GateOption + func GateTcpPort(port int) GateOption + func GateUdpPort(port int) GateOption + func GateWebsocketPort(port int) GateOption + type Meta struct + Id int64 + SvcNameConv func(string) kiwi.TSvc + SvcToVer map[string]string + type Mongo struct + type NodeConnType uint8 + const Tcp + const Udp + type NodeDialerSelector func(set *ds.Set2Item[kiwi.TSvc, int64, kiwi.INodeDialer]) (int64, *util.Err) + type NodeOption func(opt *nodeOption) + func NodeIp(ip string) NodeOption + func NodePort(port int) NodeOption + func NodeSelector(selector NodeDialerSelector) NodeOption + func NodeType(t NodeConnType) NodeOption + type OnNetDialerConnected func(*nodeDialer) + type OnNetDialerDisconnected func(*nodeDialer, *util.Err) + type Option func(*option) + func SetGate(receiver kiwi.FnAgentBytes, options ...GateOption) Option + func SetLoggers(loggers ...kiwi.ILogger) Option + func SetMeta(meta *Meta) Option + func SetMongoDB(uri, db string, options *options.DatabaseOptions) Option + func SetRedis(addr, user, pw string, db int) Option + func SetServices(services []kiwi.IService) Option + func SetWorker(active, share, parallel, global bool) Option + type RcvNtfPkt struct + func NewRcvNtfPkt() *RcvNtfPkt + func (p *RcvNtfPkt) Code() kiwi.TCode + func (p *RcvNtfPkt) Complete() + func (p *RcvNtfPkt) Err(err *util.Err) + func (p *RcvNtfPkt) Err2(code util.TErrCode, m util.M) + func (p *RcvNtfPkt) Err3(code util.TErrCode, e error) + func (p *RcvNtfPkt) Head() util.M + func (p *RcvNtfPkt) HeadId() string + func (p *RcvNtfPkt) InitWithBytes(msgType uint8, tid int64, head util.M, json bool, payload []byte) *util.Err + func (p *RcvNtfPkt) InitWithMsg(msgType uint8, tid int64, head util.M, json bool, msg util.IMsg) + func (p *RcvNtfPkt) Json() bool + func (p *RcvNtfPkt) Msg() util.IMsg + func (p *RcvNtfPkt) SenderId() int64 + func (p *RcvNtfPkt) SetWorker(typ kiwi.EWorker, key string) + func (p *RcvNtfPkt) Svc() kiwi.TSvc + func (p *RcvNtfPkt) Tid() int64 + func (p *RcvNtfPkt) Worker() kiwi.EWorker + func (p *RcvNtfPkt) WorkerKey() string + type RcvPusPkt struct + func NewRcvPusPkt() *RcvPusPkt + func (p *RcvPusPkt) Code() kiwi.TCode + func (p *RcvPusPkt) Complete() + func (p *RcvPusPkt) Err(err *util.Err) + func (p *RcvPusPkt) Err2(code util.TErrCode, m util.M) + func (p *RcvPusPkt) Err3(code util.TErrCode, e error) + func (p *RcvPusPkt) Head() util.M + func (p *RcvPusPkt) HeadId() string + func (p *RcvPusPkt) InitWithBytes(msgType uint8, tid int64, head util.M, json bool, payload []byte) *util.Err + func (p *RcvPusPkt) InitWithMsg(msgType uint8, tid int64, head util.M, json bool, msg util.IMsg) + func (p *RcvPusPkt) Json() bool + func (p *RcvPusPkt) Msg() util.IMsg + func (p *RcvPusPkt) SenderId() int64 + func (p *RcvPusPkt) SetWorker(typ kiwi.EWorker, key string) + func (p *RcvPusPkt) Svc() kiwi.TSvc + func (p *RcvPusPkt) Tid() int64 + func (p *RcvPusPkt) Worker() kiwi.EWorker + func (p *RcvPusPkt) WorkerKey() string + type RcvReqPkt struct + func NewRcvReqPkt() *RcvReqPkt + func (p *RcvReqPkt) Code() kiwi.TCode + func (p *RcvReqPkt) Complete() + func (p *RcvReqPkt) Err(err *util.Err) + func (p *RcvReqPkt) Err2(code util.TErrCode, m util.M) + func (p *RcvReqPkt) Err3(code util.TErrCode, e error) + func (p *RcvReqPkt) Fail(code uint16) + func (p *RcvReqPkt) Head() util.M + func (p *RcvReqPkt) HeadId() string + func (p *RcvReqPkt) InitWithBytes(msgType uint8, tid int64, head util.M, json bool, payload []byte) *util.Err + func (p *RcvReqPkt) InitWithMsg(msgType uint8, tid int64, head util.M, json bool, msg util.IMsg) + func (p *RcvReqPkt) Json() bool + func (p *RcvReqPkt) Msg() util.IMsg + func (p *RcvReqPkt) Ok(msg util.IMsg) + func (p *RcvReqPkt) SenderId() int64 + func (p *RcvReqPkt) SetWorker(typ kiwi.EWorker, key string) + func (p *RcvReqPkt) Svc() kiwi.TSvc + func (p *RcvReqPkt) Tid() int64 + func (p *RcvReqPkt) Worker() kiwi.EWorker + func (p *RcvReqPkt) WorkerKey() string + type Redis struct + Addr string + Db int + Password string + User string + type SNotify struct + func (n *SNotify) Dispose() + func (p *SNotify) Code() kiwi.TCode + func (p *SNotify) GetSvcNodeId() (int64, bool) + func (p *SNotify) Head() util.M + func (p *SNotify) InitHead() + func (p *SNotify) Json() bool + func (p *SNotify) Msg() util.IMsg + func (p *SNotify) Payload() []byte + func (p *SNotify) Pid() int64 + func (p *SNotify) Svc() kiwi.TSvc + func (p *SNotify) Tid() int64 + type SPush struct + func (p *SPush) Code() kiwi.TCode + func (p *SPush) Dispose() + func (p *SPush) GetSvcNodeId() (int64, bool) + func (p *SPush) Head() util.M + func (p *SPush) InitHead() + func (p *SPush) Json() bool + func (p *SPush) Msg() util.IMsg + func (p *SPush) Payload() []byte + func (p *SPush) Pid() int64 + func (p *SPush) Svc() kiwi.TSvc + func (p *SPush) Tid() int64 + type SRequest struct + func (p *SRequest) Code() kiwi.TCode + func (p *SRequest) GetSvcNodeId() (int64, bool) + func (p *SRequest) Head() util.M + func (p *SRequest) InitHead() + func (p *SRequest) Json() bool + func (p *SRequest) Msg() util.IMsg + func (p *SRequest) Payload() []byte + func (p *SRequest) Pid() int64 + func (p *SRequest) Svc() kiwi.TSvc + func (p *SRequest) Tid() int64 + func (r *SRequest) Dispose() + func (r *SRequest) Fail(head util.M, code uint16) + func (r *SRequest) Ok(head util.M, msg util.IMsg) + func (r *SRequest) OkBytes(head util.M, bytes []byte) + func (r *SRequest) SetBytesHandler(fail util.FnInt64MUint16, ok util.FnInt64MBytes) + func (r *SRequest) SetHandler(fail util.FnInt64MUint16, ok util.FnInt64MMsg) + type Worker struct