event

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiMap

type MultiMap map[string][]string

MultiMap describes a set of events together with how those events should be processed. Most often, event types are mapped to URLs, but that is not required. Event values can be any string that is meaningful to an application.

func NestedToMultiMap

func NestedToMultiMap(separator string, raw map[string]interface{}) (MultiMap, error)

NestedToMultiMap translates a map with potentially nested string keys into a MultiMap. This function is useful when unmarshalling from libraries that impose some meaning on a separator, like viper does with periods. Essentially, this function returns a MultiMap that is the result of "flattening" the given raw map.

The separator string must be nonempty. It is used as the separator for nested map keys, e.g. "foo.bar".

func (MultiMap) Add

func (m MultiMap) Add(eventType string, mappedTo ...string)

Add appends one or more values to an event type. If mappedTo is empty, this method does nothing. If the eventType doesn't exist, it is created.

func (MultiMap) Get

func (m MultiMap) Get(eventType string, fallback ...string) ([]string, bool)

Get returns the values associated with the given event type. The fallback event types, if supplied, are used if no values are present for the given eventType. The fallback is useful for defaults, e.g. m.Get("IOT", "default").

func (MultiMap) Set

func (m MultiMap) Set(eventType string, mappedTo ...string)

Set changes the given eventType so that it maps only to the values supplied in mappedTo. If mappedTo is empty, this method deletes the event type.

Jump to

Keyboard shortcuts

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