Documentation
¶
Index ¶
- Constants
- type LookupPartition
- func (p *LookupPartition) Acquire()
- func (p *LookupPartition) BusyCount() int
- func (p *LookupPartition) IsLimitExceeded() bool
- func (p *LookupPartition) Limit() int
- func (p *LookupPartition) Name() string
- func (p *LookupPartition) Percent() float64
- func (p *LookupPartition) Release()
- func (p *LookupPartition) String() string
- func (p *LookupPartition) UpdateLimit(totalLimit int32)
- type LookupPartitionStrategy
- func (s *LookupPartitionStrategy) BinBusyCount(key string) (int, error)
- func (s *LookupPartitionStrategy) BinLimit(key string) (int, error)
- func (s *LookupPartitionStrategy) BusyCount() int
- func (s *LookupPartitionStrategy) Limit() int
- func (s *LookupPartitionStrategy) SetLimit(limit int)
- func (s *LookupPartitionStrategy) String() string
- func (s *LookupPartitionStrategy) TryAcquire(ctx context.Context) (token core.StrategyToken, ok bool)
- type PredicatePartition
- func (p *PredicatePartition) Acquire()
- func (p *PredicatePartition) BusyCount() int
- func (p *PredicatePartition) IsLimitExceeded() bool
- func (p *PredicatePartition) Limit() int
- func (p *PredicatePartition) Name() string
- func (p *PredicatePartition) Percent() float64
- func (p *PredicatePartition) Release()
- func (p *PredicatePartition) String() string
- func (p *PredicatePartition) UpdateLimit(totalLimit int32)
- type PredicatePartitionStrategy
- func (s *PredicatePartitionStrategy) BinBusyCount(idx int) (int, error)
- func (s *PredicatePartitionStrategy) BinLimit(idx int) (int, error)
- func (s *PredicatePartitionStrategy) BusyCount() int
- func (s *PredicatePartitionStrategy) Limit() int
- func (s *PredicatePartitionStrategy) SetLimit(limit int)
- func (s *PredicatePartitionStrategy) String() string
- func (s *PredicatePartitionStrategy) TryAcquire(ctx context.Context) (core.StrategyToken, bool)
- type SimpleStrategy
Constants ¶
const PartitionTagName = "partition"
PartitionTagName represents the metric tag used for the partition identifier
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LookupPartition ¶
type LookupPartition struct {
MetricSampleListener core.MetricSampleListener
// contains filtered or unexported fields
}
LookupPartition defines a partition for the LookupPartitionStrategy Note: generally speaking you shouldn't use this directly, instead use the higher level LookupPartitionStrategy
func NewLookupPartitionWithMetricRegistry ¶
func NewLookupPartitionWithMetricRegistry( name string, percent float64, limit int32, registry core.MetricRegistry, ) *LookupPartition
NewLookupPartitionWithMetricRegistry will create a new LookupPartition
func (*LookupPartition) Acquire ¶
func (p *LookupPartition) Acquire()
Acquire from the worker pool note: not to be used directly, not thread safe.
func (*LookupPartition) BusyCount ¶
func (p *LookupPartition) BusyCount() int
BusyCount will return the current limit
func (*LookupPartition) IsLimitExceeded ¶
func (p *LookupPartition) IsLimitExceeded() bool
IsLimitExceeded will return true of the number of requests in flight >= limit note: not thread safe.
func (*LookupPartition) Limit ¶
func (p *LookupPartition) Limit() int
Limit will return the current limit
func (*LookupPartition) Name ¶
func (p *LookupPartition) Name() string
Name will return the partition name, these are immutable.
func (*LookupPartition) Percent ¶
func (p *LookupPartition) Percent() float64
Percent returns the partition percent, these are immutable
func (*LookupPartition) Release ¶
func (p *LookupPartition) Release()
Release from the worker pool note: not to be used directly, not thread safe.
func (*LookupPartition) String ¶
func (p *LookupPartition) String() string
func (*LookupPartition) UpdateLimit ¶
func (p *LookupPartition) UpdateLimit(totalLimit int32)
UpdateLimit will update the current limit Calculate this bin's limit while rounding up and ensuring the value is at least 1. With this technique the sum of bin limits may end up being higher than the concurrency limit.
type LookupPartitionStrategy ¶
type LookupPartitionStrategy struct {
// contains filtered or unexported fields
}
LookupPartitionStrategy defines the strategy for partitioning the limiter by named groups where the allocation of group to percentage is provided up front.
func NewLookupPartitionStrategyWithMetricRegistry ¶
func NewLookupPartitionStrategyWithMetricRegistry( partitions map[string]*LookupPartition, lookupFunc func(ctx context.Context) string, limit int32, registry core.MetricRegistry, ) (*LookupPartitionStrategy, error)
NewLookupPartitionStrategyWithMetricRegistry will create a new LookupPartitionStrategy
func (*LookupPartitionStrategy) BinBusyCount ¶
func (s *LookupPartitionStrategy) BinBusyCount(key string) (int, error)
BinBusyCount will return the current bin's busy count
func (*LookupPartitionStrategy) BinLimit ¶
func (s *LookupPartitionStrategy) BinLimit(key string) (int, error)
BinLimit will return the current bin's limit
func (*LookupPartitionStrategy) BusyCount ¶
func (s *LookupPartitionStrategy) BusyCount() int
BusyCount will return the current busy count.
func (*LookupPartitionStrategy) Limit ¶
func (s *LookupPartitionStrategy) Limit() int
Limit will return the current limit.
func (*LookupPartitionStrategy) SetLimit ¶
func (s *LookupPartitionStrategy) SetLimit(limit int)
SetLimit will set a new limit for the LookupPartitionStrategy and it's partitions
func (*LookupPartitionStrategy) String ¶
func (s *LookupPartitionStrategy) String() string
func (*LookupPartitionStrategy) TryAcquire ¶
func (s *LookupPartitionStrategy) TryAcquire(ctx context.Context) (token core.StrategyToken, ok bool)
TryAcquire a token from a partition
type PredicatePartition ¶
type PredicatePartition struct {
MetricSampleListener core.MetricSampleListener
// contains filtered or unexported fields
}
PredicatePartition defines a partition for the PredicatePartitionStrategy Note: generally speaking you shouldn't use this directly, instead use the higher level PredicatePartitionStrategy
func NewPredicatePartitionWithMetricRegistry ¶
func NewPredicatePartitionWithMetricRegistry( name string, percent float64, predicateFunc func(ctx context.Context) bool, registry core.MetricRegistry, ) *PredicatePartition
NewPredicatePartitionWithMetricRegistry will create a new PredicatePartition
func (*PredicatePartition) Acquire ¶
func (p *PredicatePartition) Acquire()
Acquire from the worker pool note: not to be used directly, not thread safe.
func (*PredicatePartition) BusyCount ¶
func (p *PredicatePartition) BusyCount() int
BusyCount will return the current limit
func (*PredicatePartition) IsLimitExceeded ¶
func (p *PredicatePartition) IsLimitExceeded() bool
IsLimitExceeded will return true of the number of requests in flight >= limit note: not thread safe.
func (*PredicatePartition) Limit ¶
func (p *PredicatePartition) Limit() int
Limit will return the current limit
func (*PredicatePartition) Name ¶
func (p *PredicatePartition) Name() string
Name will return the partition name, these are immutable.
func (*PredicatePartition) Percent ¶
func (p *PredicatePartition) Percent() float64
Percent returns the partition percent, these are immutable
func (*PredicatePartition) Release ¶
func (p *PredicatePartition) Release()
Release from the worker pool note: not to be used directly, not thread safe.
func (*PredicatePartition) String ¶
func (p *PredicatePartition) String() string
func (*PredicatePartition) UpdateLimit ¶
func (p *PredicatePartition) UpdateLimit(totalLimit int32)
UpdateLimit will update the current limit Calculate this bin's limit while rounding up and ensuring the value is at least 1. With this technique the sum of bin limits may end up being higher than the concurrency limit.
type PredicatePartitionStrategy ¶
type PredicatePartitionStrategy struct {
// contains filtered or unexported fields
}
PredicatePartitionStrategy is a concurrency limiter that guarantees a certain percentage of the limit to specific callers while allowing callers to borrow from underutilized callers.
Callers are identified by their index into an array of percentages passed in during initialization. A percentage of 0.0 means that a caller may only use excess capacity and can be completely starved when the limit is reached. A percentage of 1.0 means that the caller is guaranteed to get the entire limit.
grpc.server.call.inflight (group=[a, b, c]) grpc.server.call.limit (group=[a,b,c])
func NewPredicatePartitionStrategyWithMetricRegistry ¶
func NewPredicatePartitionStrategyWithMetricRegistry( partitions []*PredicatePartition, limit int32, registry core.MetricRegistry, ) (*PredicatePartitionStrategy, error)
NewPredicatePartitionStrategyWithMetricRegistry will create a new PredicatePartitionStrategy
func (*PredicatePartitionStrategy) BinBusyCount ¶
func (s *PredicatePartitionStrategy) BinBusyCount(idx int) (int, error)
BinBusyCount will return the current bin's busy count
func (*PredicatePartitionStrategy) BinLimit ¶
func (s *PredicatePartitionStrategy) BinLimit(idx int) (int, error)
BinLimit will return the current bin's limit
func (*PredicatePartitionStrategy) BusyCount ¶
func (s *PredicatePartitionStrategy) BusyCount() int
BusyCount will return the current busy count.
func (*PredicatePartitionStrategy) Limit ¶
func (s *PredicatePartitionStrategy) Limit() int
Limit will return the current limit.
func (*PredicatePartitionStrategy) SetLimit ¶
func (s *PredicatePartitionStrategy) SetLimit(limit int)
SetLimit will set a new limit for the PredicatePartitionStrategy and it's partitions
func (*PredicatePartitionStrategy) String ¶
func (s *PredicatePartitionStrategy) String() string
func (*PredicatePartitionStrategy) TryAcquire ¶
func (s *PredicatePartitionStrategy) TryAcquire(ctx context.Context) (core.StrategyToken, bool)
TryAcquire a token from a partition
type SimpleStrategy ¶
type SimpleStrategy struct {
// contains filtered or unexported fields
}
SimpleStrategy is the simplest strategy for enforcing a concurrency limit that has a single counter for tracking total usage.
func NewSimpleStrategy ¶
func NewSimpleStrategy(limit int) *SimpleStrategy
NewSimpleStrategy will create a new SimpleStrategy
func NewSimpleStrategyWithMetricRegistry ¶
func NewSimpleStrategyWithMetricRegistry(limit int, registry core.MetricRegistry, tags ...string) *SimpleStrategy
NewSimpleStrategyWithMetricRegistry will create a new SimpleStrategy
func (*SimpleStrategy) GetBusyCount ¶
func (s *SimpleStrategy) GetBusyCount() int
GetBusyCount will get the current busy count
func (*SimpleStrategy) GetLimit ¶
func (s *SimpleStrategy) GetLimit() int
GetLimit will get the current limit
func (*SimpleStrategy) SetLimit ¶
func (s *SimpleStrategy) SetLimit(limit int)
SetLimit will update the strategy with a new limit.
func (*SimpleStrategy) String ¶
func (s *SimpleStrategy) String() string
func (*SimpleStrategy) TryAcquire ¶
func (s *SimpleStrategy) TryAcquire(ctx context.Context) (token core.StrategyToken, ok bool)
TryAcquire will try to acquire a token from the limiter. context Context of the request for partitioned limits. returns not ok if limit is exceeded, or a StrategyToken that must be released when the operation completes.