Skip to content

Commit 4b74bcf

Browse files
committed
add comments on AutoScalerOptions
1 parent 14144a2 commit 4b74bcf

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

internal/internal_poller_autoscaler.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,30 @@ const (
3535

3636
type (
3737
AutoScalerOptions struct {
38-
Enabled bool
39-
MinCount int
40-
MaxCount int
41-
Cooldown time.Duration
38+
// Optional: Enable the auto scaler.
39+
// default: false
40+
Enabled bool
41+
42+
// Optional: The cooldown period after a scale up or down.
43+
// default: 10 seconds
44+
Cooldown time.Duration
45+
46+
// Optional: The minimum number of pollers to start with.
47+
// default: 2
48+
PollerMinCount int
49+
50+
// Optional: The maximum number of pollers to start with.
51+
// default: 200
52+
PollerMaxCount int
53+
54+
// Optional: The upper bound of poller wait time for poller autoscaler to scale down.
55+
// default: 256ms
56+
// NOTE: This is normally not needed to be set by user.
4257
PollerWaitTimeUpperBound time.Duration
58+
59+
// Optional: The lower bound of poller wait time for poller autoscaler to scale up.
60+
// default: 16ms
61+
// NOTE: This is normally not needed to be set by user.
4362
PollerWaitTimeLowerBound time.Duration
4463
}
4564
)

internal/internal_worker.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,11 +1290,11 @@ func AugmentWorkerOptions(options WorkerOptions) WorkerOptions {
12901290
}
12911291

12921292
func augmentAutoScalerOptions(options AutoScalerOptions) AutoScalerOptions {
1293-
if options.MinCount <= 1 {
1294-
options.MinCount = defaultMinPollerSize
1293+
if options.PollerMinCount <= 1 {
1294+
options.PollerMinCount = defaultMinPollerSize
12951295
}
1296-
if options.MaxCount <= 1 {
1297-
options.MaxCount = defaultMaxPollerSize
1296+
if options.PollerMaxCount <= 1 {
1297+
options.PollerMaxCount = defaultMaxPollerSize
12981298
}
12991299
if options.Cooldown == 0 {
13001300
options.Cooldown = defaultPollerAutoScalerCooldown

internal/internal_worker_base.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ func newBaseWorker(options baseWorkerOptions, logger *zap.Logger, metricsScope t
181181
concurrencyAS = worker.NewConcurrencyAutoScaler(worker.ConcurrencyAutoScalerInput{
182182
Concurrency: concurrency,
183183
Cooldown: pollerOptions.Cooldown,
184-
PollerMaxCount: pollerOptions.MaxCount,
185-
PollerMinCount: pollerOptions.MinCount,
184+
PollerMaxCount: pollerOptions.PollerMaxCount,
185+
PollerMinCount: pollerOptions.PollerMinCount,
186186
PollerWaitTimeUpperBound: pollerOptions.PollerWaitTimeUpperBound,
187187
PollerWaitTimeLowerBound: pollerOptions.PollerWaitTimeLowerBound,
188188
Logger: logger,

internal/internal_worker_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,8 @@ func Test_augmentWorkerOptions(t *testing.T) {
13201320
Authorization: nil,
13211321
AutoScalerOptions: AutoScalerOptions{
13221322
Enabled: true,
1323-
MinCount: 10,
1324-
MaxCount: 20,
1323+
PollerMinCount: 10,
1324+
PollerMaxCount: 20,
13251325
Cooldown: time.Minute * 3,
13261326
PollerWaitTimeUpperBound: time.Millisecond * 200,
13271327
PollerWaitTimeLowerBound: time.Millisecond * 100,
@@ -1360,8 +1360,8 @@ func Test_augmentWorkerOptions(t *testing.T) {
13601360
Authorization: nil,
13611361
AutoScalerOptions: AutoScalerOptions{
13621362
Enabled: true,
1363-
MinCount: 10,
1364-
MaxCount: 20,
1363+
PollerMinCount: 10,
1364+
PollerMaxCount: 20,
13651365
Cooldown: time.Minute * 3,
13661366
PollerWaitTimeUpperBound: time.Millisecond * 200,
13671367
PollerWaitTimeLowerBound: time.Millisecond * 100,
@@ -1404,8 +1404,8 @@ func Test_augmentWorkerOptions(t *testing.T) {
14041404
Authorization: nil,
14051405
AutoScalerOptions: AutoScalerOptions{
14061406
Enabled: false,
1407-
MinCount: 2,
1408-
MaxCount: 200,
1407+
PollerMinCount: 2,
1408+
PollerMaxCount: 200,
14091409
Cooldown: time.Second * 10,
14101410
PollerWaitTimeUpperBound: time.Millisecond * 256,
14111411
PollerWaitTimeLowerBound: time.Millisecond * 16,

0 commit comments

Comments
 (0)