Documentation ¶
Index ¶
- Constants
- Variables
- func DateTime() string
- func Now() time.Time
- func NowString() string
- func StartClock()
- func StopClock()
- func WallClock() *datetime.Clock
- type Endpoint
- type EndpointFlag
- type EndpointMap
- func (e *EndpointMap) Add(node NodeID, endpoint Endpoint)
- func (e *EndpointMap) Delete(node NodeID) bool
- func (e *EndpointMap) Get(node NodeID) Endpoint
- func (e *EndpointMap) List() []Endpoint
- func (e *EndpointMap) Range(f func(Endpoint) bool)
- func (e *EndpointMap) Reset()
- func (e *EndpointMap) Size() int
- type IPacket
- type MessageEndpoint
- type NodeID
- type NodeIDSet
- type PacketFlag
- type PacketHandler
- type PacketType
- type Service
- type ServiceContext
Constants ¶
View Source
const ( SERVICE_ALL = 0xFF INSTANCE_ALL = 0xFFFF )
View Source
const ( NodeServiceShift = 16 NodeServiceMask = 0xFF00FFFF NodeInstanceMask = 0xFFFF0000 NodeTypeShift = 31 )
View Source
const VERSION = "1.3.15"
Variables ¶
View Source
var (
ClockEpoch int64 = 1577836800 // 2020-01-01 00:00:00 UTC
)
Functions ¶
Types ¶
type Endpoint ¶
type Endpoint interface { MessageEndpoint RawConn() net.Conn Stats() *stats.Stats Go(EndpointFlag) // 加密解密 SetEncryptPair(cipher.BlockCryptor, cipher.BlockCryptor) }
网络连接端点
type EndpointFlag ¶ added in v1.1.0
type EndpointFlag uint32
const ( EndpointReader EndpointFlag = 0x01 EndpointWriter EndpointFlag = 0x02 EndpointReadWriter EndpointFlag = 0x03 )
type EndpointMap ¶
线程安全的endpoint map
func NewEndpointMap ¶
func NewEndpointMap() *EndpointMap
func (*EndpointMap) Add ¶
func (e *EndpointMap) Add(node NodeID, endpoint Endpoint)
func (*EndpointMap) Delete ¶
func (e *EndpointMap) Delete(node NodeID) bool
func (*EndpointMap) Get ¶
func (e *EndpointMap) Get(node NodeID) Endpoint
func (*EndpointMap) List ¶
func (e *EndpointMap) List() []Endpoint
func (*EndpointMap) Range ¶ added in v1.3.15
func (e *EndpointMap) Range(f func(Endpoint) bool)
func (*EndpointMap) Reset ¶
func (e *EndpointMap) Reset()
func (*EndpointMap) Size ¶
func (e *EndpointMap) Size() int
type IPacket ¶
type IPacket interface { Command() int32 SetCommand(int32) Seq() int16 SetSeq(int16) Type() PacketType SetType(PacketType) Flag() PacketFlag SetFlag(PacketFlag) Errno() int32 SetErrno(ec int32) Refers() []NodeID SetRefers([]NodeID) Endpoint() MessageEndpoint SetEndpoint(MessageEndpoint) Clone() IPacket SetBody(v interface{}) IBody() interface{} BodyToInt() int64 BodyToFloat() float64 BodyToString() string BodyToBytes() []byte DecodeTo(msg proto.Message) error Decode() error Reply(command int32, body interface{}) error ReplyMsg(ack proto.Message) error Refuse(errno int32) error RefuseWith(command, errno int32) error }
定义应用层消息接口
type MessageEndpoint ¶
type NodeID ¶
type NodeID uint32
节点号
func MakeNodeID ¶
func MustParseNodeID ¶
func (NodeID) IsTypeBackend ¶
type PacketFlag ¶
type PacketFlag uint8
消息标志位
const ( PFlagCompressed PacketFlag = 0x01 // 压缩 PFlagEncrypted PacketFlag = 0x02 // 加密 PFlagError PacketFlag = 0x10 // 错误标记 )
type PacketHandler ¶ added in v1.3.5
type PacketType ¶
type PacketType int8
消息编码类型
const ( PTypePacket PacketType = 0 // 应用消息 PTypeRoute PacketType = 1 // 路由消息 )
type Service ¶
type Service interface { Type() int8 Name() string NodeID() NodeID SetNodeID(id NodeID) ServiceContext() *ServiceContext Init(*ServiceContext) error Startup() error }
定义应用层服务接口
type ServiceContext ¶
type ServiceContext struct {
// contains filtered or unexported fields
}
服务的上下文
func NewServiceContext ¶
func NewServiceContext(ctx context.Context, srv Service, queueSize int) *ServiceContext
func (*ServiceContext) Close ¶
func (c *ServiceContext) Close()
func (*ServiceContext) Context ¶
func (c *ServiceContext) Context() context.Context
func (*ServiceContext) MessageQueue ¶
func (c *ServiceContext) MessageQueue() chan IPacket
func (*ServiceContext) Service ¶
func (c *ServiceContext) Service() Service
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
x
|
|
uuid
This package provides immutable UUID structs and the functions NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 and 5 UUIDs as specified in RFC 4122.
|
This package provides immutable UUID structs and the functions NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 and 5 UUIDs as specified in RFC 4122. |
Click to show internal directories.
Click to hide internal directories.