Documentation ¶
Overview ¶
Package topics provides some helpers for managing topics in memory.
Index ¶
- type NameGroup
- func (g *NameGroup) Add(name string, id ulid.ULID)
- func (g *NameGroup) AddTopic(topic *api.Topic) (err error)
- func (g *NameGroup) Contains(s string) bool
- func (g *NameGroup) ContainsTopicHash(hash []byte) bool
- func (g *NameGroup) ContainsTopicID(topicID ulid.ULID) bool
- func (g *NameGroup) ContainsTopicName(name string) bool
- func (g *NameGroup) FilterTopicID(topicIDs ...ulid.ULID) *NameGroup
- func (g *NameGroup) FilterTopicName(names ...string) *NameGroup
- func (g *NameGroup) Length() int
- func (g *NameGroup) TopicMap() map[string][]byte
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 ¶
Add a topic reference to the names group consisting of the topic name and ID.
func (*NameGroup) Contains ¶
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 ¶
Check if the name group contains the specified topic hash.
func (*NameGroup) ContainsTopicID ¶
Check if the name group contains the specified topicID
func (*NameGroup) ContainsTopicName ¶
Check if the name group contains the specified topic name
func (*NameGroup) FilterTopicID ¶
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 ¶
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.