Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoscaleSettings ¶
type AutoscaleSettings struct { Concurrency int MaxConcurrency int AutoscaleFrequency time.Duration ThroughputBucketCount int ThroughputBucketDuration time.Duration MaximumBufferedItemsPerRepo int }
func DefaultAutoscaleSettings ¶
func DefaultAutoscaleSettings() AutoscaleSettings
DefaultAutoscaleSettings returns the default autoscale settings. Concurrency is the number of workers to start with. MaxConcurrency is the maximum number of workers to scale up to. AutoscaleFrequency is the frequency to check the average throughput. ThroughputBucketCount is the number of buckets to use to calculate the average throughput. ThroughputBucketDuration is the duration of each bucket. By default we check the average throughput over the last 60 seconds with 1 second buckets We make an autoscaling decision every 5 seconds. We start with 1 worker and scale up to 32 workers.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is a scheduler that will scale up and down the number of workers based on the throughput of the workers.
func NewScheduler ¶
func NewScheduler(autoscaleSettings AutoscaleSettings, ident string, do func(context.Context, *events.XRPCStreamEvent) error) *Scheduler
type ThroughputManager ¶
type ThroughputManager struct {
// contains filtered or unexported fields
}
ThroughputManager keeps track of the number of tasks processed per bucketDuration over a specified bucketCount.
func NewThroughputManager ¶
func NewThroughputManager(bucketCount int, bucketDuration time.Duration) *ThroughputManager
NewThroughputManager creates a new ThroughputManager with the specified interval.
func (*ThroughputManager) Add ¶
func (m *ThroughputManager) Add(n int)
Add increments the count of tasks processed in the current bucket
func (*ThroughputManager) AvgThroughput ¶
func (m *ThroughputManager) AvgThroughput() float64
AvgThroughput returns the average number of tasks processed per bucketDuration over the past bucketCount buckets.
func (*ThroughputManager) Start ¶
func (m *ThroughputManager) Start()
Start starts the ThroughputManager It ticks every bucketDuration, shifting the position in the circular buffer.
func (*ThroughputManager) Stop ¶
func (m *ThroughputManager) Stop()