message

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicInvalid = uint8(iota)
	TopicStatic
	TopicWildcard
	TopicWildcardSymbol      = '*'
	TopicMultiWildcardSymbol = "..."
	TopicSeparator           = '.' // The separator character.
	TopicMaxDepth            = 100 // Maximum depth for topic using a separator

	// Wildcard wildcard is hash for wildcard topic such as '*' or '...'
	Wildcard = uint32(857445537)
)

Various constant on Topic.

View Source
const (
	// MasterContract contract is default contract used for topics if client program does not specify Contract in the request.
	MasterContract = uint32(3376684800)
)

Various constant parts of the ID.

Variables

This section is empty.

Functions

func Prefix added in v0.1.1

func Prefix(parts []Part) uint64

Prefix generates unique ID from topic parts and concatenate contract as first part of the topic.

Types

type ID

type ID []byte

ID represents a message ID and lexigraphically sortable.

func NewID

func NewID(seq uint64) ID

NewID generates a new message identifier with a prefix. Master contract is adde to the ID and actual Contract is set later.

func (ID) EvalPrefix

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

EvalPrefix matches the prefix with the cutoff time.

func (ID) Prefix added in v0.1.1

func (id ID) Prefix() ID

Prefix return message ID only containing prefix.

func (ID) Sequence added in v0.1.1

func (id ID) Sequence() uint64

Sequence gets the seq for the id.

func (*ID) SetContract added in v0.1.1

func (id *ID) SetContract(contract uint32)

SetContract sets Contract on ID.

func (ID) Size added in v0.1.1

func (id ID) Size() int

Size return fixed size of the ID.

type Part

type Part struct {
	Hash      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 uint32) 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() (uint32, bool)

TTL returns a Time-To-Live option.

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