metadata

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constraint

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

Constraint is a struct representing a constraint that should be applied to the metadata of for example a Message

func (Constraint) Field

func (c Constraint) Field() string

Field returns the metadata string field

func (Constraint) Operator

func (c Constraint) Operator() Operator

Operator returns the operator

func (Constraint) Value

func (c Constraint) Value() interface{}

Value returns the scalar value

type Matcher

type Matcher interface {
	// Iterate calls the callback for each constraint
	Iterate(callback func(constraint Constraint))
}

Matcher is a struct used to register constraints that should be applied to the metadata of for example a Message

func NewMatcher

func NewMatcher() Matcher

NewMatcher return a new Matcher instance without any constraints

func WithConstraint

func WithConstraint(parent Matcher, field string, operator Operator, value interface{}) Matcher

WithConstraint add a constraint to the matcher

type Metadata

type Metadata interface {
	// Value returns the value associated with this context for key, or nil
	// if no value is associated with key. Successive calls to Value with
	// the same key returns the same result.
	Value(key string) interface{}

	// AsMap return the Metadata as a map[string]interface{}
	AsMap() map[string]interface{}
}

Metadata is an immutable map[string]interface{} implementation

func FromMap

func FromMap(data map[string]interface{}) Metadata

FromMap returns a new Metadata instance filled with the map data

func New

func New() Metadata

New return a new Metadata instance without any information

func UnmarshalJSON

func UnmarshalJSON(json []byte) (Metadata, error)

UnmarshalJSON unmarshals the provided json into a Metadata instance

func WithValue

func WithValue(parent Metadata, key string, val interface{}) Metadata

WithValue returns a copy of parent in which the value associated with key is val.

type Operator

type Operator string

Operator represents a operation for a constraint

const (
	// Equals is a mathematical symbol used to indicate equality.
	// It is also a Drama/Science fiction film from 2015.
	Equals Operator = "="
	// GreaterThan is a mathematical symbol that denotes an inequality between two values.
	// It is typically placed between the two values being compared and signals that the first number is greater than the second number.
	GreaterThan Operator = ">"
	// GreaterThanEquals is a mathematical symbol that denotes an inequality between two values.
	// It is typically placed between the two values being compared and signals that the first number is greater than or equal to the second number.
	GreaterThanEquals Operator = ">="
	// LowerThan is a mathematical symbol that denotes an inequality between two values.
	// It is typically placed between the two values being compared and signals that the first number is less than the second number.
	LowerThan Operator = "<"
	// LowerThanEquals is a mathematical symbol that denotes an inequality between two values.
	// It is typically placed between the two values being compared and signals that the first number is less than or equal to the second number.
	LowerThanEquals Operator = "<="
	// NotEquals is a mathematical symbol that denotes an inequality between two values.
	// It is typically placed between the two values being compared and signals that the first number is not equal the second number.
	NotEquals Operator = "!="
)

Jump to

Keyboard shortcuts

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