paramtools

package
v0.0.0-...-93b6c00 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: BSD-3-Clause Imports: 5 Imported by: 19

Documentation

Overview

Package paramtools provides Params and ParamSet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParamMatcher

type ParamMatcher []ParamSet

ParamMatcher is a list of Paramsets that can be matched against. The primary purpose is to match against a set of rules, e.g. ignore rules.

func (ParamMatcher) MatchAny

func (p ParamMatcher) MatchAny(params ParamSet) bool

MatchAny returns true if the given ParamSet matches any of the rules in the matcher.

func (ParamMatcher) MatchAnyParams

func (p ParamMatcher) MatchAnyParams(params Params) bool

MatchAnyParams returns true if the given Params matches any of the rules in the matcher.

type ParamSet

type ParamSet map[string][]string

ParamSet is a set of keys and the possible values that the keys could have. I.e. the []string should contain no duplicates.

func NewParamSet

func NewParamSet(ps ...Params) ParamSet

NewParamSet returns a new ParamSet initialized with the given maps of parameters.

func (ParamSet) AddParamSet

func (p ParamSet) AddParamSet(ps map[string][]string)

AddParamSet adds the ParamSet or ReadOnlyParamSet to this ParamSet.

func (ParamSet) AddParams

func (p ParamSet) AddParams(ps Params)

AddParams adds the Params to this ParamSet.

func (ParamSet) AddParamsFromKey

func (p ParamSet) AddParamsFromKey(key string)

AddParamsFromKey is the same as calling

paramset.AddParams(NewParams(key))

but without creating the intermediate Params.

It presumes a valid key, i.e. something that passed query.ValidateKey.

func (ParamSet) CartesianProduct

func (p ParamSet) CartesianProduct(keys []string) (<-chan Params, error)

CartesianProduct returns a channel of Params that represent the Cartesian Product of all the values for the given keys.

func (ParamSet) Copy

func (p ParamSet) Copy() ParamSet

Copy returns a copy of the ParamSet.

func (ParamSet) Equal

func (p ParamSet) Equal(right map[string][]string) bool

Equal returns true if the given Paramset contain exactly the same keys and associated values as this one. Side Effect: both ParamSets will be normalized after this call (their values will be sorted) if they have the same number of keys.

func (ParamSet) Freeze

func (p ParamSet) Freeze() ReadOnlyParamSet

Freeze returns the ReadOnlyParamSet version of the ParamSet.

It is up to the caller to make sure the original ParamSet is not modified, or call FrozenCopy() instead.

func (ParamSet) FrozenCopy

func (p ParamSet) FrozenCopy() ReadOnlyParamSet

FrozenCopy returns a copy of the ParamSet as a ReadOnlyParamSet.

func (ParamSet) Keys

func (p ParamSet) Keys() []string

Keys returns the keys of the ParamSet.

func (ParamSet) Matches

func (p ParamSet) Matches(right ParamSet) bool

Matches returns true if the params in 'p' match the sets given in 'right'. For every key in 'p' there has to be a matching key in 'right' and the intersection of their values must be not empty.

func (ParamSet) MatchesParams

func (p ParamSet) MatchesParams(right Params) bool

MatchesParams returns true if the params in 'p' match the values given in 'right'. For every key in 'p' there has to be a matching key in 'right' and the intersection of their values must be not empty.

func (ParamSet) Normalize

func (p ParamSet) Normalize()

Normalize all the values by sorting them.

func (ParamSet) Size

func (p ParamSet) Size() int

Size returns the total number of values in the ParamSet.

type Params

type Params map[string]string

Params is a set of key,value pairs.

func NewParams

func NewParams(key string) Params

NewParams returns the parsed structured key (see query) as Params.

It presumes a valid key, i.e. something that passed query.IsValid.

func (Params) Add

func (p Params) Add(b ...Params)

Add adds each set of Params in order to this Params.

Values in p will be overwritten.

func (Params) Copy

func (p Params) Copy() Params

Copy returns a copy of the Params.

func (Params) Equal

func (p Params) Equal(a Params) bool

Equal returns true if this Params equals a.

func (Params) Keys

func (p Params) Keys() []string

Keys returns the keys of the Params.

type ReadOnlyParamSet

type ReadOnlyParamSet map[string][]string

ReadOnlyParamSet is a ParamSet that doesn't allow offer any mutating methods.

Note that you can still modify the map, but hopefully the name along with the removal of the mutating methods will catch most of the mis-uses.

func NewReadOnlyParamSet

func NewReadOnlyParamSet(ps ...Params) ReadOnlyParamSet

NewReadOnlyParamSet returns a new ReadOnlyParamSet initialized with the given maps of parameters.

func (ReadOnlyParamSet) CartesianProduct

func (p ReadOnlyParamSet) CartesianProduct(keys []string) (<-chan Params, error)

CartesianProduct returns a channel of Params that represent the Cartesian Product of all the values for the given keys.

func (ReadOnlyParamSet) Keys

func (p ReadOnlyParamSet) Keys() []string

Keys returns the keys of the ReadOnlyParamSet.

func (ReadOnlyParamSet) Matches

func (p ReadOnlyParamSet) Matches(right ReadOnlyParamSet) bool

Matches returns true if the params in 'p' match the sets given in 'right'. For every key in 'p' there has to be a matching key in 'right' and the intersection of their values must be not empty.

func (ReadOnlyParamSet) MatchesParams

func (p ReadOnlyParamSet) MatchesParams(right Params) bool

MatchesParams returns true if the params in 'p' match the values given in 'right'. For every key in 'p' there has to be a matching key in 'right' and the intersection of their values must be not empty.

func (ReadOnlyParamSet) Size

func (p ReadOnlyParamSet) Size() int

Size returns the total number of values in the ReadOnlyParamSet.

Jump to

Keyboard shortcuts

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