Documentation
¶
Index ¶
- Variables
- func CollectId(id uint64)
- func DelMapContext(ctx context.Context, key interface{})
- func DeleteSlice(slice interface{}, index int) (interface{}, error)
- func GetAvailableId() uint64
- func GetContextMap(ctx context.Context) (m *sync.Map, ok bool)
- func GetId() uint64
- func GetMapContext(ctx context.Context, key interface{}) interface{}
- func GetNowTimeMillisecond() int64
- func IF(b bool, t1, t2 interface{}) interface{}
- func NewContextMap(ctx context.Context) context.Context
- func NowTimeFormat() string
- func OnServiceHandle(session defs.ISession, packet defs.IPacket) bool
- func ParseDataByJson(data []byte, req interface{}) bool
- func ParseDataByProtobuf(data []byte, req interface{}) bool
- func ParseMethodNameBySuffix(methodName string) (name string, err error)
- func RegisterService(rcvr interface{})
- func SerializeDataByJson(d interface{}, param ...interface{}) []byte
- func SerializeDataByProtobuf(d interface{}, param ...interface{}) []byte
- func SetMapContext(ctx context.Context, key, value interface{})
- func Slice(s string) (b []byte)
- func String(b []byte) (s string)
- func Struct2Map(obj interface{}) map[string]interface{}
- func WaitExit(fList ...func())
- func WaitSignal()
- type ConsistentHash
- func (ch *ConsistentHash) Add(node string)
- func (ch *ConsistentHash) AddNodes(nodes []string)
- func (ch *ConsistentHash) GetNode(key string) string
- func (ch *ConsistentHash) GetNodeIdx(hash uint32) int
- func (ch *ConsistentHash) Remove(node string)
- func (ch *ConsistentHash) RemoveNodes(nodes []string)
- type HeapTimer
- type IdGenerator
- type Item
- type PriorityQueue
- func (pq *PriorityQueue) Get(maxPriority int64) *Item
- func (pq PriorityQueue) Len() int
- func (pq PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) Peek() *Item
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) Push(x interface{})
- func (pq PriorityQueue) Swap(i, j int)
- func (pq *PriorityQueue) Update(item *Item, v interface{}, priority int64)
- type SafeQueue
- type ServiceFactory
- func (sf *ServiceFactory) IsExported(name string) bool
- func (sf *ServiceFactory) IsExportedOrBuiltinType(t reflect.Type) bool
- func (sf *ServiceFactory) OnServiceHandle(session defs.ISession, packet defs.IPacket) bool
- func (sf *ServiceFactory) Register(rcvr interface{}, cb ...defs.ParseMethodNameCallback)
- func (sf *ServiceFactory) SetParseDataCallback(cb defs.ParseDataCallback)
- func (sf *ServiceFactory) SetParseMethodNameCallback(cb defs.ParseMethodNameCallback)
- func (sf *ServiceFactory) SetSerializeDataCallback(cb defs.SerializeDataCallback)
- type SortUint32
- type Timer
- type Trie
- type TrieNode
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NullData = []byte("{}") NullDataEx = []byte("") TypeOfContext = reflect.TypeOf((*context.Context)(nil)).Elem() TypeOfError = reflect.TypeOf((*error)(nil)).Elem() TypeOfInt = reflect.TypeOf((*int)(nil)).Elem() )
View Source
var (
GenerateIdError = errors.New("Generate Id failed")
)
View Source
var SliceIsNilError = errors.New("slice is nil")
Functions ¶
func DelMapContext ¶
func DeleteSlice ¶
func GetAvailableId ¶
func GetAvailableId() uint64
func GetMapContext ¶
func GetNowTimeMillisecond ¶
func GetNowTimeMillisecond() int64
func NowTimeFormat ¶
func NowTimeFormat() string
func ParseDataByJson ¶
func ParseDataByProtobuf ¶
func ParseMethodNameBySuffix ¶
func RegisterService ¶
func RegisterService(rcvr interface{})
func SerializeDataByJson ¶
func SerializeDataByJson(d interface{}, param ...interface{}) []byte
func SerializeDataByProtobuf ¶
func SerializeDataByProtobuf(d interface{}, param ...interface{}) []byte
func SetMapContext ¶
func Struct2Map ¶
func Struct2Map(obj interface{}) map[string]interface{}
func WaitSignal ¶
func WaitSignal()
Types ¶
type ConsistentHash ¶
func NewConsistentHash ¶
func NewConsistentHash(initReplicasNum ...int) *ConsistentHash
func (*ConsistentHash) Add ¶
func (ch *ConsistentHash) Add(node string)
func (*ConsistentHash) AddNodes ¶
func (ch *ConsistentHash) AddNodes(nodes []string)
func (*ConsistentHash) GetNode ¶
func (ch *ConsistentHash) GetNode(key string) string
func (*ConsistentHash) GetNodeIdx ¶
func (ch *ConsistentHash) GetNodeIdx(hash uint32) int
func (*ConsistentHash) Remove ¶
func (ch *ConsistentHash) Remove(node string)
func (*ConsistentHash) RemoveNodes ¶
func (ch *ConsistentHash) RemoveNodes(nodes []string)
type HeapTimer ¶
type HeapTimer struct {
// contains filtered or unexported fields
}
func NewHeapTimer ¶
type IdGenerator ¶
type IdGenerator struct {
// contains filtered or unexported fields
}
func NewIdGenerator ¶
func NewIdGenerator() *IdGenerator
func (*IdGenerator) CycleCount ¶
func (idg *IdGenerator) CycleCount() uint64
func (*IdGenerator) Get ¶
func (idg *IdGenerator) Get() (id uint64)
func (*IdGenerator) GetAvailableId ¶
func (idg *IdGenerator) GetAvailableId() (id uint64)
func (*IdGenerator) Put ¶
func (idg *IdGenerator) Put(id uint64)
type PriorityQueue ¶
type PriorityQueue []*Item
func NewPriorityQueue ¶
func NewPriorityQueue(capacity int) PriorityQueue
func (*PriorityQueue) Get ¶
func (pq *PriorityQueue) Get(maxPriority int64) *Item
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Peek ¶
func (pq *PriorityQueue) Peek() *Item
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)
func (*PriorityQueue) Update ¶
func (pq *PriorityQueue) Update(item *Item, v interface{}, priority int64)
type SafeQueue ¶
type SafeQueue struct {
// contains filtered or unexported fields
}
func NewSafeQueue ¶
func NewSafeQueue() *SafeQueue
type ServiceFactory ¶
type ServiceFactory struct { ParseMethodNameCallback defs.ParseMethodNameCallback ParseDataCallback defs.ParseDataCallback // contains filtered or unexported fields }
func GetMsgFactory ¶
func GetMsgFactory() *ServiceFactory
func NewServiceFactory ¶
func NewServiceFactory() *ServiceFactory
func (*ServiceFactory) IsExported ¶
func (sf *ServiceFactory) IsExported(name string) bool
func (*ServiceFactory) IsExportedOrBuiltinType ¶
func (sf *ServiceFactory) IsExportedOrBuiltinType(t reflect.Type) bool
func (*ServiceFactory) OnServiceHandle ¶
func (*ServiceFactory) Register ¶
func (sf *ServiceFactory) Register(rcvr interface{}, cb ...defs.ParseMethodNameCallback)
func (*ServiceFactory) SetParseDataCallback ¶
func (sf *ServiceFactory) SetParseDataCallback(cb defs.ParseDataCallback)
func (*ServiceFactory) SetParseMethodNameCallback ¶
func (sf *ServiceFactory) SetParseMethodNameCallback(cb defs.ParseMethodNameCallback)
func (*ServiceFactory) SetSerializeDataCallback ¶
func (sf *ServiceFactory) SetSerializeDataCallback(cb defs.SerializeDataCallback)
type SortUint32 ¶
type SortUint32 []uint32
func (SortUint32) Len ¶
func (su SortUint32) Len() int
func (SortUint32) Less ¶
func (su SortUint32) Less(i, j int) bool
func (SortUint32) Swap ¶
func (su SortUint32) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.