codec

package
v0.0.0-...-5c0346e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LenAclVersion       = 4
	LenArray            = 4
	LenChildVersion     = 4
	LenCreated          = LenTime
	LenCreatedZxId      = LenZxId
	LenDataLength       = 4
	LenEphemeralOwner   = 8
	LenError            = 4
	LenFlags            = 4
	LenLastModified     = LenTime
	LenLastModifiedZxId = LenZxId
	LenLastZxidSeen     = LenZxId
	LenLength           = 4
	LenNumberOfChildren = 4
	LenOpCode           = 4
	LenPeerZxId         = LenZxId
	LenPermission       = 4
	LenProtocolVersion  = 4
	LenReadonly         = 1
	LenSessionId        = 8
	LenTime             = 8
	LenTimeout          = 4
	LenTransactionId    = 4
	LenVersion          = 4
	LenWatch            = 1
	LenZxId             = 8
)

Variables

View Source
var (
	PasswordEmpty = make([]byte, 16)
)

Functions

func BytesLen

func BytesLen(bytes []byte) int

func PanicToError

func PanicToError(r any, stack []byte) error

func StrLen

func StrLen(str string) int

Types

type Acl

type Acl struct {
	Perms int
	Id    *Id
}

func DecodeAcl

func DecodeAcl(bytes []byte) (acl *Acl, err error)

func (*Acl) ByteLength

func (a *Acl) ByteLength() int

type CloseReq

type CloseReq struct {
	TransactionId int
	OpCode        OpCode
}

func DecodeCloseReq

func DecodeCloseReq(bytes []byte) (req *CloseReq, err error)

func (*CloseReq) Bytes

func (c *CloseReq) Bytes(containLen bool) []byte

func (*CloseReq) BytesLength

func (c *CloseReq) BytesLength(containLen bool) int

type CloseResp

type CloseResp struct {
	TransactionId int
	ZxId          int64
	Error         ErrorCode
}

func DecodeCloseResp

func DecodeCloseResp(bytes []byte) (resp *CloseResp, err error)

func (*CloseResp) Bytes

func (c *CloseResp) Bytes(containLen bool) []byte

func (*CloseResp) BytesLength

func (c *CloseResp) BytesLength(containLen bool) int

type ConnectReq

type ConnectReq struct {
	ProtocolVersion int
	LastZxidSeen    int64
	Timeout         int
	SessionId       int64
	Password        []byte
	ReadOnly        bool
}

func DecodeConnectReq

func DecodeConnectReq(bytes []byte) (req *ConnectReq, err error)

func (*ConnectReq) Bytes

func (c *ConnectReq) Bytes(containLen bool) []byte

func (*ConnectReq) BytesLength

func (c *ConnectReq) BytesLength(containLen bool) int

type ConnectResp

type ConnectResp struct {
	ProtocolVersion int
	Timeout         int
	SessionId       int64
	Password        []byte
	ReadOnly        bool
}

func DecodeConnectResp

func DecodeConnectResp(bytes []byte) (resp *ConnectResp, err error)

func (*ConnectResp) Bytes

func (c *ConnectResp) Bytes(containLen bool) []byte

func (*ConnectResp) BytesLength

func (c *ConnectResp) BytesLength(containLen bool) int

type CreateReq

type CreateReq struct {
	TransactionId int
	OpCode        OpCode
	Path          string
	Data          []byte
	Permissions   []int
	Scheme        string
	Credentials   string
	Flags         int
}

func DecodeCreateReq

func DecodeCreateReq(bytes []byte) (req *CreateReq, err error)

func (*CreateReq) Bytes

func (c *CreateReq) Bytes(containLen bool) []byte

func (*CreateReq) BytesLength

func (c *CreateReq) BytesLength(containLen bool) int

type CreateResp

type CreateResp struct {
	TransactionId int
	ZxId          int64
	Error         ErrorCode
	Path          string
}

func DecodeCreateResp

func DecodeCreateResp(bytes []byte) (resp *CreateResp, err error)

func (*CreateResp) Bytes

func (c *CreateResp) Bytes() []byte

func (*CreateResp) BytesLength

func (c *CreateResp) BytesLength() int

type DataNode

type DataNode struct {
	Path     string
	Data     []byte
	Acl      int64
	Stat     *StatPersisted
	Children []*DataNode
}

type DeleteReq

type DeleteReq struct {
	TransactionId int
	OpCode        OpCode
	Path          string
	Version       int
}

func DecodeDeleteReq

func DecodeDeleteReq(bytes []byte) (req *DeleteReq, err error)

func (*DeleteReq) Bytes

func (e *DeleteReq) Bytes(containLen bool) []byte

func (*DeleteReq) BytesLength

func (e *DeleteReq) BytesLength(containLen bool) int

type DeleteResp

type DeleteResp struct {
	TransactionId int
	ZxId          int64
	Error         ErrorCode
}

func DecodeDeleteResp

func DecodeDeleteResp(bytes []byte) (resp *DeleteResp, err error)

func (*DeleteResp) Bytes

func (c *DeleteResp) Bytes() []byte

func (*DeleteResp) BytesLength

func (c *DeleteResp) BytesLength() int

type ErrorCode

type ErrorCode int32
const (
	EC_NoNodeError     ErrorCode = -101
	EC_NodeExistsError ErrorCode = -110
	EC_OK              ErrorCode = 0
)

type ExistsReq

type ExistsReq struct {
	TransactionId int
	OpCode        OpCode
	Path          string
	Watch         bool
}

func DecodeExistsReq

func DecodeExistsReq(bytes []byte) (req *ExistsReq, err error)

func (*ExistsReq) Bytes

func (e *ExistsReq) Bytes(containLen bool) []byte

func (*ExistsReq) BytesLength

func (e *ExistsReq) BytesLength(containLen bool) int

type ExistsResp

type ExistsResp struct {
	TransactionId int
	ZxId          int64
	Error         ErrorCode
	Stat          *Stat
}

func DecodeExistsResp

func DecodeExistsResp(bytes []byte) (resp *ExistsResp, err error)

func (*ExistsResp) Bytes

func (c *ExistsResp) Bytes() []byte

func (*ExistsResp) BytesLength

func (c *ExistsResp) BytesLength() int

type GetChildrenReq

type GetChildrenReq struct {
	TransactionId int
	OpCode        OpCode
	Path          string
	Watch         bool
}

func DecodeGetChildrenReq

func DecodeGetChildrenReq(bytes []byte) (req *GetChildrenReq, err error)

func (*GetChildrenReq) Bytes

func (g *GetChildrenReq) Bytes(containLen bool) []byte

func (*GetChildrenReq) BytesLength

func (g *GetChildrenReq) BytesLength(containLen bool) int

type GetChildrenResp

type GetChildrenResp struct {
	TransactionId int
	ZxId          int64
	Error         ErrorCode
	Children      []string
}

func DecodeGetChildrenResp

func DecodeGetChildrenResp(bytes []byte) (resp *GetChildrenResp, err error)

func (*GetChildrenResp) Bytes

func (c *GetChildrenResp) Bytes() []byte

func (*GetChildrenResp) BytesLength

func (c *GetChildrenResp) BytesLength() int

type GetDataReq

type GetDataReq struct {
	TransactionId int
	OpCode        OpCode
	Path          string
	Watch         bool
}

func DecodeGetDataReq

func DecodeGetDataReq(bytes []byte) (req *GetDataReq, err error)

func (*GetDataReq) Bytes

func (e *GetDataReq) Bytes(containLen bool) []byte

func (*GetDataReq) BytesLength

func (e *GetDataReq) BytesLength(containLen bool) int

type GetDataResp

type GetDataResp struct {
	TransactionId int
	ZxId          int64
	Data          []byte
	Error         ErrorCode
	Stat          *Stat
}

func DecodeGetDataResp

func DecodeGetDataResp(bytes []byte) (resp *GetDataResp, err error)

func (*GetDataResp) Bytes

func (c *GetDataResp) Bytes() []byte

func (*GetDataResp) BytesLength

func (c *GetDataResp) BytesLength() int

type Id

type Id struct {
	Scheme string
	Id     string
}

func DecodeId

func DecodeId(bytes []byte) (id *Id, err error)

func (*Id) ByteLength

func (i *Id) ByteLength() int

type OpCode

type OpCode int32
const (
	OP_ERROR          OpCode = -1
	OP_CREATE_SESSION OpCode = -10
	OP_CLOSE_SESSION  OpCode = -11
)
const (
	OP_NOTIFICATION OpCode = iota
	OP_CREATE
	OP_DELETE
	OP_EXISTS
	OP_GET_DATA
	OP_SET_DATA
	OP_GET_ACL
	OP_SET_ACL
	OP_GET_CHILDREN
	OP_SYNC
	OP_PING
	OP_GET_CHILDREN2
	OP_CHECK
	OP_MULTI
	OP_CREATE2
	OP_RECONFIG
	OP_CHECK_WATCHES
	OP_REMOVE_WATCHES
	OP_CREATE_CONTAINER
	OP_DELETE_CONTAINER
	OP_CREATE_TTL
	OP_MULTI_READ
)
const (
	OP_AUTH OpCode = iota + 100
	OP_SET_WATCHES
	OP_SASL
	OP_GET_EPHEMERALS
	OP_GET_ALL_CHILDREN_NUMBER
	OP_SET_WATCHES2
	OP_ADD_WATCH
	OP_WHO_AM_I
)

type SetDataReq

type SetDataReq struct {
	TransactionId int
	OpCode        OpCode
	Path          string
	Data          []byte
	Version       int
}

func DecodeSetDataReq

func DecodeSetDataReq(bytes []byte) (req *SetDataReq, err error)

func (*SetDataReq) Bytes

func (s *SetDataReq) Bytes(containLen bool) []byte

func (*SetDataReq) BytesLength

func (s *SetDataReq) BytesLength(containLen bool) int

type SetDataResp

type SetDataResp struct {
	TransactionId int
	ZxId          int64
	Error         ErrorCode
	Stat          *Stat
}

func DecodeSetDataResp

func DecodeSetDataResp(bytes []byte) (resp *SetDataResp, err error)

func (*SetDataResp) Bytes

func (s *SetDataResp) Bytes() []byte

func (*SetDataResp) BytesLength

func (s *SetDataResp) BytesLength() int

type Snapshot

type Snapshot struct {
	Magic      string
	Version    int
	DbId       int64
	SessionMap map[int64]int
	AclMap     map[int64][]*Acl
	Root       *DataNode
	NodeMap    map[string]*DataNode
	NodeCount  int
}

func DecodeSnapshot

func DecodeSnapshot(bytes []byte) (s *Snapshot, err error)

type Stat

type Stat struct {
	CreatedZxId              int64
	LastModifiedZxId         int64
	Created                  int64
	LastModified             int64
	Version                  int
	ChildVersion             int
	AclVersion               int
	EphemeralOwner           int64
	DataLength               int
	NumChildren              int
	LastModifiedChildrenZxId int64
}

func DecodeStat

func DecodeStat(bytes []byte) (stat *Stat, err error)

func (*Stat) Bytes

func (s *Stat) Bytes() []byte

func (*Stat) BytesLength

func (s *Stat) BytesLength() int

type StatPersisted

type StatPersisted struct {
	CreatedZxId      int64
	LastModifiedZxId int64
	Created          int64
	LastModified     int64
	Version          int
	ChildVersion     int
	AclVersion       int
	EphemeralOwner   int64
	PeerZxId         int64
}

func DecodeStatPersisted

func DecodeStatPersisted(bytes []byte) (stat *StatPersisted, err error)

func (*StatPersisted) BytesLength

func (s *StatPersisted) BytesLength() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL