Documentation ¶
Index ¶
Constants ¶
const ( RateLimiterScopeFunction = "function_name" RateLimiterScopeConnection = "connection" RateLimiterScopeTable = "table" )
Variables ¶
This section is empty.
Functions ¶
func FormatStringMap ¶
FormatStringMap orders the map keys and returns a string containing all map keys and values
func GetMaxConcurrentRows ¶
func GetMaxConcurrentRows() int
func MergeScopeValues ¶
MergeScopeValues combines a set of scope values in order of precedence NOT: it adds the given values to the resulting map WITHOUT OVERWRITING existing values i.e. follow the precedence order
func ScopeValuesString ¶
Types ¶
type Definition ¶
type Definition struct { // the limiter name Name string // the actual limiter config FillRate rate.Limit BucketSize int64 // the max concurrency supported MaxConcurrency int64 // the scope properties which identify this limiter instance // one limiter instance will be created for each combination of these properties which is encountered Scope []string // filter used to target the limiter Where string // contains filtered or unexported fields }
func DefinitionFromProto ¶
func DefinitionFromProto(p *proto.RateLimiterDefinition) (*Definition, error)
DefinitionFromProto converts the proto format RateLimiterDefinition into a Defintion
func (*Definition) Initialise ¶
func (d *Definition) Initialise() error
func (*Definition) SatisfiesFilters ¶
func (d *Definition) SatisfiesFilters(scopeValues map[string]string) bool
SatisfiesFilters returns whether the given values satisfy ANY of our filters
func (*Definition) String ¶
func (d *Definition) String() string
func (*Definition) ToProto ¶
func (d *Definition) ToProto() *proto.RateLimiterDefinition
func (*Definition) Validate ¶
func (d *Definition) Validate() []string
type HydrateLimiter ¶
type HydrateLimiter struct { Name string // contains filtered or unexported fields }
func (*HydrateLimiter) String ¶
func (d *HydrateLimiter) String() string
type LimiterMap ¶
type LimiterMap struct {
// contains filtered or unexported fields
}
LimiterMap is a struct encapsulating a map of rate limiters map key is built from the limiter tag values, e.g. tags: {"connection": "aws1", "region": "us-east-1"} key: hash("{\"connection\": \"aws1\", \"region\": \"us-east-1\"})
func NewLimiterMap ¶
func NewLimiterMap() *LimiterMap
func (*LimiterMap) Clear ¶
func (m *LimiterMap) Clear()
func (*LimiterMap) GetOrCreate ¶
func (m *LimiterMap) GetOrCreate(def *Definition, scopeValues map[string]string) (*HydrateLimiter, error)
GetOrCreate checks the map for a limiter with the specified key values - if none exists it creates it
type MultiLimiter ¶
type MultiLimiter struct { Limiters []*HydrateLimiter ScopeValues map[string]string }
func EmptyMultiLimiter ¶
func EmptyMultiLimiter() *MultiLimiter
func NewMultiLimiter ¶
func NewMultiLimiter(limiters []*HydrateLimiter, scopeValues map[string]string) *MultiLimiter
func (*MultiLimiter) LimiterNames ¶
func (m *MultiLimiter) LimiterNames() []string
func (*MultiLimiter) ReleaseSemaphore ¶
func (m *MultiLimiter) ReleaseSemaphore()
func (*MultiLimiter) String ¶
func (m *MultiLimiter) String() string
func (*MultiLimiter) TryToAcquireSemaphore ¶
func (m *MultiLimiter) TryToAcquireSemaphore() bool