Documentation ¶
Index ¶
- Constants
- func BytesToString(b []byte) string
- func RegistSerializerGenerator(vType byte, f SerializerGenerator) error
- func StringToBytes(v string) ([]byte, error)
- type Bytes
- type Int64
- type KVPair
- type Map
- type Queue
- func (q *Queue) Decode(b []byte) ([]byte, error)
- func (q *Queue) Encode() ([]byte, error)
- func (q *Queue) Front() QueueElement
- func (q *Queue) Init()
- func (q *Queue) Len() int
- func (q *Queue) PopFront() (interface{}, bool)
- func (q *Queue) PushBack(v Serializer)
- func (q *Queue) PushBackQueue(q2 *Queue)
- func (q *Queue) Remove(e QueueElement)
- type QueueElement
- type Serializer
- type SerializerGenerator
- type String
- type Uint32
Constants ¶
const ( VTypeBytes byte = 0x01 VTypeString byte = 0x02 VTypeInt8 byte = 0x03 VTypeInt16 byte = 0x04 VTypeInt32 byte = 0x05 VTypeInt64 byte = 0x06 VTypeUint8 byte = 0x07 VTypeUint16 byte = 0x08 VTypeUint32 byte = 0x09 VTypeUint64 byte = 0x0a VTypeMap byte = 0x0b VTypeQueue byte = 0x0c VTypeBorrowRecord byte = 0x30 VTypeLimiterMeta byte = 0x31 )
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
func RegistSerializerGenerator ¶
func RegistSerializerGenerator(vType byte, f SerializerGenerator) error
注册Serializer生成器
func StringToBytes ¶
Types ¶
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
type KVPair ¶
type KVPair struct { K string V Serializer }
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func (*Map) Encode ¶
Encode encode map to format which used to binary persist Encoded Format: > [1 byte] data type > [4 bytes] pair's count of the map > -------------------------------------------- > [1 byte] type of the key > [4 bytes] byte count of key's encoded result > [N bytes] content of encoded key > [1 byte] type of value > [4 bytes] byte count of value's encoded result > [N bytes] content of encoded value > -------------------------------------------- > ... > ... > ...
func (*Map) Set ¶
func (m *Map) Set(k string, v Serializer)
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue implement of Serializer interface{}
func (*Queue) Encode ¶
Encode encode queue to format which used to binary persist Encoded Format: > [1 byte] data type > [4 bytes] element's count of the queue > -------------------------------------------- > [1 byte] type of the first element > [4 bytes] byte count of the first element's encoded result > [N bytes] the first element's encoded result > -------------------------------------------- > ... > ... > ...
func (*Queue) Front ¶
func (q *Queue) Front() QueueElement
func (*Queue) PopFront ¶
PopFront pop the first element from queue, if not found, then false will be returned
func (*Queue) PushBack ¶
func (q *Queue) PushBack(v Serializer)
func (*Queue) PushBackQueue ¶
func (*Queue) Remove ¶
func (q *Queue) Remove(e QueueElement)
type QueueElement ¶
type QueueElement struct {
// contains filtered or unexported fields
}
QueueElement is an element of a queue
func (QueueElement) IsNil ¶
func (e QueueElement) IsNil() bool
func (QueueElement) Next ¶
func (e QueueElement) Next() QueueElement
func (QueueElement) Value ¶
func (e QueueElement) Value() interface{}
type Serializer ¶
type Serializer interface { // Encode encode object to []byte Encode() ([]byte, error) // Decode decode from []byte to object // If decode success, byte sequeue will be removed from input []byte and then return Decode([]byte) ([]byte, error) }
func SerializerFactory ¶
func SerializerFactory(vType byte) (Serializer, error)
Serializer工厂函数,生成Serializer实例
type String ¶
type String struct {
// contains filtered or unexported fields
}