codec

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clonable added in v1.15.0

type Clonable interface {
	// Clone should return a deep copy of the state.
	Clone() interface{}
}

type Codec

type Codec interface {
	Decode([]byte) (interface{}, error)
	Encode(interface{}) ([]byte, error)

	DecodeMultiKey(map[string][]byte) (interface{}, error)
	EncodeMultiKey(interface{}) (map[string][]byte, error)

	// CodecID is a short identifier to communicate what codec should be used to decode the value.
	// Once in use, this should be stable to avoid confusing other clients.
	CodecID() string
}

Codec allows KV clients to serialise and deserialise values.

type MultiKey added in v1.15.0

type MultiKey interface {
	Clonable

	// SplitByID Split interface in array of key and value. THe key is a unique identifier of an instance in the ring. The value is
	// interface with its data. The interface resultant need to be a proto.Message
	SplitByID() map[string]interface{}

	// JoinIds update the current interface to add receiving key value information. The key is an unique identifier for an instance.
	// The value is the information for that instance.
	JoinIds(in map[string]interface{})

	// GetItemFactory method to be used for deserilaize the value information from an instance
	GetItemFactory() proto.Message

	// FindDifference returns the difference between two Multikeys. The returns are an interface which also implements Multikey
	// with an array of keys which were changed, and an array of strings which are unique identifiers deleted. An error is
	// returned when that does not implement the correct codec
	FindDifference(that MultiKey) (interface{}, []string, error)
}

type Proto

type Proto struct {
	// contains filtered or unexported fields
}

Proto is a Codec for proto/snappy

func NewProtoCodec added in v0.7.0

func NewProtoCodec(id string, factory func() proto.Message) Proto

func (Proto) CodecID added in v0.7.0

func (p Proto) CodecID() string

func (Proto) Decode

func (p Proto) Decode(bytes []byte) (interface{}, error)

Decode implements Codec

func (Proto) DecodeMultiKey added in v1.15.0

func (p Proto) DecodeMultiKey(data map[string][]byte) (interface{}, error)

DecodeMultiKey implements Codec

func (Proto) Encode

func (p Proto) Encode(msg interface{}) ([]byte, error)

Encode implements Codec

func (Proto) EncodeMultiKey added in v1.15.0

func (p Proto) EncodeMultiKey(msg interface{}) (map[string][]byte, error)

EncodeMultiKey implements Codec

type String

type String struct{}

String is a code for strings.

func (String) CodecID added in v0.7.0

func (String) CodecID() string

func (String) Decode

func (String) Decode(bytes []byte) (interface{}, error)

Decode implements Codec.

func (String) DecodeMultiKey added in v1.15.0

func (String) DecodeMultiKey(map[string][]byte) (interface{}, error)

func (String) Encode

func (String) Encode(msg interface{}) ([]byte, error)

Encode implements Codec.

func (String) EncodeMultiKey added in v1.15.0

func (String) EncodeMultiKey(msg interface{}) (map[string][]byte, error)

Jump to

Keyboard shortcuts

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