names

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func struct {
	// Match should return true when topic matches pattern.
	Match func(pattern, topic string) bool
	// contains filtered or unexported fields
}

Func is an abstraction allowing simplified implementation of topic.Names implementations. It tracks a unique set of topics, updating when Add or Remove is called. Then, when Search is called, Func calls Match for each unique topic stored and each pattern sent to Search.

See exmaple implementations: Exact & Prefix.

func Prefix

func Prefix(topics ...string) *Func

Prefix is a Func

func (*Func) Add

func (a *Func) Add(topics ...string)

Add topics to internal unique set.

func (*Func) Remove

func (a *Func) Remove(topics ...string)

Remove topics from internal unique set.

func (*Func) Search

func (a *Func) Search(patterns ...string) (topics []string)

Search returns all unique topics stored matching one of the topics patterns. It calls the configured Match function to determine whether the stored topic matches a pattern.

type Proxy

type Proxy struct{}

Proxy does nothing to the topics received by Search. Those topics are simply returned. Use this when all topics are absolute (no wildcards).

func (*Proxy) Add

func (a *Proxy) Add(...string)

Add does nothing.

func (*Proxy) Remove

func (a *Proxy) Remove(...string)

Remove does nothing.

func (*Proxy) Search

func (a *Proxy) Search(topics ...string) []string

Search returns topics.

Jump to

Keyboard shortcuts

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