github.com/15mga/kiwi@v0.0.2-0.20240324021231-b95d5c3ac751/rcv_pkt.go (about)

     1  package kiwi
     2  
     3  import "github.com/15mga/kiwi/util"
     4  
     5  type FnRcvPkt func(IRcvPkt)
     6  type FnRcvPus func(IRcvPush)
     7  type FnRcvReq func(IRcvRequest)
     8  
     9  type EWorker uint8
    10  
    11  const (
    12  	EWorkerGo     EWorker = iota
    13  	EWorkerActive         //需要key
    14  	EWorkerShare          //需要key
    15  	EWorkerGlobal
    16  	EWorkerSelf
    17  )
    18  
    19  type IRcvPkt interface {
    20  	SenderId() int64
    21  	Tid() int64
    22  	Svc() TSvc
    23  	Code() TCode
    24  	Head() util.M
    25  	HeadId() string
    26  	Json() bool
    27  	Msg() util.IMsg
    28  	SetWorker(typ EWorker, key string)
    29  	Worker() EWorker
    30  	WorkerKey() string
    31  	InitWithBytes(msgType uint8, tid int64, head util.M, json bool, bytes []byte) *util.Err
    32  	InitWithMsg(msgType uint8, tid int64, head util.M, json bool, msg util.IMsg)
    33  	Complete()
    34  	Err(err *util.Err)
    35  	Err2(code util.TErrCode, m util.M)
    36  	Err3(code util.TErrCode, e error)
    37  }
    38  
    39  type IRcvPush interface {
    40  	IRcvPkt
    41  }
    42  
    43  type IRcvRequest interface {
    44  	IRcvPkt
    45  	Ok(msg util.IMsg)
    46  	Fail(code uint16)
    47  }
    48  
    49  type IRcvNotice interface {
    50  	IRcvPkt
    51  }