topics

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package topics provides some helpers for managing topics in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NameGroup

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

A topics group is a set of related topics (e.g. topics that belong to the same project) that allow easy lookups between topic names and IDs for easy referencing. TODO: should name groups also handle name hashes?

func (*NameGroup) Add

func (g *NameGroup) Add(name string, id ulid.ULID)

Add a topic reference to the names group consisting of the topic name and ID.

func (*NameGroup) AddTopic

func (g *NameGroup) AddTopic(topic *api.Topic) (err error)

Add a topic reference from the topic api struct.

func (*NameGroup) Contains

func (g *NameGroup) Contains(s string) bool

Contains checks if the string is contained by the name group. It first checks to see if the string is a valid topic name, and if so it checks the names hash; then it checks if the string is a parseable ulid, and if so it checks the ID field. Finally, it checks if the string is a base64 encoded topic hash, and checks the name hashes.

func (*NameGroup) ContainsTopicHash

func (g *NameGroup) ContainsTopicHash(hash []byte) bool

Check if the name group contains the specified topic hash.

func (*NameGroup) ContainsTopicID

func (g *NameGroup) ContainsTopicID(topicID ulid.ULID) bool

Check if the name group contains the specified topicID

func (*NameGroup) ContainsTopicName

func (g *NameGroup) ContainsTopicName(name string) bool

Check if the name group contains the specified topic name

func (*NameGroup) FilterTopicID

func (g *NameGroup) FilterTopicID(topicIDs ...ulid.ULID) *NameGroup

Filter the topics name group by the specified topicIDs, returning the subset of topics that are both in the original named group and specified by the list of IDs. E.g. if the topicID is in the original name group it is kept, otherwise it is omitted. A new NameGroup is returned, the original is not modified.

func (*NameGroup) FilterTopicName

func (g *NameGroup) FilterTopicName(names ...string) *NameGroup

Filter the topics name group by the specified topic names, returning the subset of topics that are both in the original named group and specified by the list of names. E.g. if the name is in the original name group it is kept, otherwise it is omitted. A new NameGroup is returned, the original is not modified.

func (*NameGroup) Length

func (g *NameGroup) Length() int

Returns the number of items in the name group.

func (*NameGroup) TopicMap

func (g *NameGroup) TopicMap() map[string][]byte

TopicMap returns a map of topic name to topic ID bytes, which is used in StreamReady messages from the server, and also to easily perform lookups in leveldb indices.

Jump to

Keyboard shortcuts

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