Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRateInvalid = errors.New("rate must be greater that zero")
ErrRateInvalid is the error that signals about invalid rate value
Functions ¶
This section is empty.
Types ¶
type NamespaceRule ¶
type NamespaceRule struct { Rule // contains filtered or unexported fields }
NamespaceRule is the one of the rule types
func NewNamespaceRule ¶
func NewNamespaceRule(record RateRecord) (*NamespaceRule, error)
NewNamespaceRule is the constructor for NamespaceRule
func (*NamespaceRule) Match ¶
func (rule *NamespaceRule) Match(namespace string) bool
Match tries to match specified string with namespace regular expression
type NamespacedPodRule ¶
type NamespacedPodRule struct { Rule // contains filtered or unexported fields }
NamespacedPodRule is the one of the rule types
func NewNamespacedPodRule ¶
func NewNamespacedPodRule(record RateRecord) (*NamespacedPodRule, error)
NewNamespacedPodRule is the constructor for NamespacedPodRule
func (*NamespacedPodRule) Match ¶
func (rule *NamespacedPodRule) Match(namespace, pod string) bool
Match tries to match specified pair with namespace and pod regular expressions
type PodRule ¶
type PodRule struct { Rule // contains filtered or unexported fields }
PodRule is the one of the rule types
func NewPodRule ¶
func NewPodRule(record RateRecord) (*PodRule, error)
NewPodRule is the constructor for PodRule
type RateRecord ¶
RateRecord is the struct to unmarshal yaml list item to
type RateRecordsProvider ¶
type RateRecordsProvider interface {
RateRecords() ([]RateRecord, error)
}
RateRecordsProvider is the records provider interface
type RateRecordsProviderStub ¶
type RateRecordsProviderStub struct{}
RateRecordsProviderStub is the stub that returns empty list of rate records
func NewRuleRecordsProviderStub ¶
func NewRuleRecordsProviderStub() *RateRecordsProviderStub
NewRuleRecordsProviderStub is the constructor for RateRecordsProviderStub
func (*RateRecordsProviderStub) RateRecords ¶
func (provider *RateRecordsProviderStub) RateRecords() ([]RateRecord, error)
RateRecords returns empty list of rate records
type RateRecordsProviderYaml ¶
type RateRecordsProviderYaml struct {
// contains filtered or unexported fields
}
RateRecordsProvider is the implementation of records provider that tries to get them from yaml file
func NewRateRecordsProviderYaml ¶
func NewRateRecordsProviderYaml(filePath string) *RateRecordsProviderYaml
NewRateRecordsProviderYaml is the constructor for RateRecordsProvider
func (*RateRecordsProviderYaml) RateRecords ¶
func (provider *RateRecordsProviderYaml) RateRecords() ([]RateRecord, error)
RateRecords should be used to obtain records from list containing yaml
type Rater ¶
type Rater struct { sync.RWMutex NamespacedPodRules []*NamespacedPodRule PodRules []*PodRule NamespaceRules []*NamespaceRule // contains filtered or unexported fields }
Rater is the structure that is used for getting rates according to regexp rules received from provider
func NewRater ¶
func NewRater(provider RateRecordsProvider, rateDefault float64) (*Rater, error)
NewRater is the constructor for Rater