message

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MasterContract contract is default contract used for topics if client program does not specify Contract in the request
	MasterContract = uint32(3376684800)
	// Wildcard wildcard is hash for wildcard topic such as '*'
	Wildcard = uint32(857445537)

	None      = uint32(0)      // ID has no flags.
	Encrypted = uint32(1 << 0) // ID has encryption set.

)

Various constant parts of the ID.

View Source
const (
	TopicInvalid = uint8(iota)
	TopicStatic
	TopicWildcard
	TopicAnySeparator         = '*'
	TopicChildrenAllSeparator = "..."
	TopicSeparator            = '.'   // The separator character.
	MaxMessageSize            = 65536 // Maximum message size allowed.
	TopicMaxDepth             = 100   // Maximum depth for topic using a separator
)

Various constant on Topic

Variables

This section is empty.

Functions

func Contract

func Contract(parts []Part) uint64

Contract generates contract from parts and concatenate contract and first part of the topic

Types

type ID

type ID []byte

ID represents a message ID encoded at 128bit and lexigraphically sortable

func NewID

func NewID(seq uint64, encrypted bool) ID

NewID generates a new message identifier without containing a prefix. Prefix is set later when arrives.

func (*ID) AddContract

func (id *ID) AddContract(contract uint64)

AddContract adds a Contract to ID, it is used to validate prefix.

func (ID) Contract

func (id ID) Contract() uint64

Contract gets the contract for the id.

func (ID) EvalPrefix

func (id ID) EvalPrefix(contract uint64, cutoff int64) bool

EvalPrefix matches the prefix with the cutoff time.

func (ID) IsEncrypted

func (id ID) IsEncrypted() bool

IsEncrypted return if an encryption is set on ID

func (ID) Seq

func (id ID) Seq() uint64

Seq gets the seq for the id.

func (ID) SetEncryption

func (id ID) SetEncryption()

SetEncryption sets an encryption on ID

type Part

type Part struct {
	Query     uint32
	Wildchars uint8
}

Part represents a parsed topic parts broken based on topic separator.

type Topic

type Topic struct {
	Topic        []byte // Gets or sets the topic string.
	TopicOptions []byte
	Parts        []Part
	Depth        uint8
	Options      []TopicOption // Gets or sets the options.
	TopicType    uint8
}

Topic represents a parsed topic.

func (*Topic) AddContract

func (t *Topic) AddContract(contract uint32)

AddContract adds contract to the parts of a topic.

func (*Topic) GetHash

func (t *Topic) GetHash(contract uint64) uint64

GetHash combines the parts into a single hash.

func (*Topic) GetHashCode

func (t *Topic) GetHashCode() uint32

GetHashCode combines the topic parts into a single hash.

func (*Topic) Last

func (t *Topic) Last() (time.Time, int, bool)

Last returns the 'last' option, which is a number of messages to retrieve.

func (*Topic) Marshal

func (t *Topic) Marshal() []byte

Marshal serializes topic to binary

func (*Topic) Parse

func (t *Topic) Parse(contract uint32, wildcard bool)

Parse attempts to parse the static vs wildcard topic

func (*Topic) ParseKey

func (t *Topic) ParseKey(text []byte)

ParseKey attempts to parse the key

func (*Topic) TTL

func (t *Topic) TTL() (int64, bool)

TTL returns a Time-To-Live option.

func (*Topic) Target

func (t *Topic) Target() uint32

Target returns the topic (first element of the query, second element of Parts)

func (*Topic) Unmarshal

func (t *Topic) Unmarshal(data []byte) error

Unmarshal de-serializes topic from binary data

type TopicOption

type TopicOption struct {
	Key   string
	Value string
}

TopicOption represents a key/value pair option.

Jump to

Keyboard shortcuts

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