Documentation ¶
Overview ¶
Package paramtools provides Params and ParamSet.
Index ¶
- type ParamMatcher
- type ParamSet
- func (p ParamSet) AddParamSet(ps map[string][]string)
- func (p ParamSet) AddParams(ps Params)
- func (p ParamSet) AddParamsFromKey(key string)
- func (p ParamSet) CartesianProduct(keys []string) (<-chan Params, error)
- func (p ParamSet) Copy() ParamSet
- func (p ParamSet) Equal(right map[string][]string) bool
- func (p ParamSet) Freeze() ReadOnlyParamSet
- func (p ParamSet) FrozenCopy() ReadOnlyParamSet
- func (p ParamSet) Keys() []string
- func (p ParamSet) Matches(right ParamSet) bool
- func (p ParamSet) MatchesParams(right Params) bool
- func (p ParamSet) Normalize()
- func (p ParamSet) Size() int
- type Params
- type ReadOnlyParamSet
- func (p ReadOnlyParamSet) CartesianProduct(keys []string) (<-chan Params, error)
- func (p ReadOnlyParamSet) Keys() []string
- func (p ReadOnlyParamSet) Matches(right ReadOnlyParamSet) bool
- func (p ReadOnlyParamSet) MatchesParams(right Params) bool
- func (p ReadOnlyParamSet) Size() int
- func (p ReadOnlyParamSet) ToString() (string, error)
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 ¶
ParamSet is a set of keys and the possible values that the keys could have. I.e. the []string should contain no duplicates.
func FromString ¶
FromString creates a new paramset object from json string.
func NewParamSet ¶
NewParamSet returns a new ParamSet initialized with the given maps of parameters.
func (ParamSet) AddParamSet ¶
AddParamSet adds the ParamSet or ReadOnlyParamSet to this ParamSet.
func (ParamSet) AddParamsFromKey ¶
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 ¶
CartesianProduct returns a channel of Params that represent the Cartesian Product of all the values for the given keys.
func (ParamSet) Equal ¶
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) Matches ¶
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 ¶
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.
type Params ¶
Params is a set of key,value pairs.
func NewParams ¶
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 ¶
Add adds each set of Params in order to this Params.
Values in p will be overwritten.
type ReadOnlyParamSet ¶
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.
func (ReadOnlyParamSet) ToString ¶
func (p ReadOnlyParamSet) ToString() (string, error)
ToString returns a json string representation of the paramset.