-
Notifications
You must be signed in to change notification settings - Fork 1
/
bucketized_field_array_pool_config.gen.go
55 lines (46 loc) · 1.65 KB
/
bucketized_field_array_pool_config.gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// This file was automatically generated by genny.
// Any changes will be lost if this file is regenerated.
// see https://github.com/mauricelam/genny
package field
import (
"github.com/m3db/m3/src/x/instrument"
)
// FieldArrayBucketConfiguration contains configuration for a pool bucket.
type FieldArrayBucketConfiguration struct {
// The count of the items in the bucket.
Count int `yaml:"count"`
// The capacity of each item in the bucket.
Capacity int `yaml:"capacity"`
}
// NewBucket creates a new bucket.
func (c *FieldArrayBucketConfiguration) NewBucket() FieldArrayBucket {
return FieldArrayBucket{
Capacity: c.Capacity,
Count: c.Count,
}
}
// BucketizedFieldArrayPoolConfiguration contains configuration for bucketized pools.
type BucketizedFieldArrayPoolConfiguration struct {
// The pool bucket configuration.
Buckets []FieldArrayBucketConfiguration `yaml:"buckets"`
// The watermark configuration.
Watermark FieldArrayPoolWatermarkConfiguration `yaml:"watermark"`
}
// NewPoolOptions creates a new set of pool options.
func (c *BucketizedFieldArrayPoolConfiguration) NewPoolOptions(
instrumentOptions instrument.Options,
) *FieldArrayPoolOptions {
return NewFieldArrayPoolOptions().
SetInstrumentOptions(instrumentOptions).
SetRefillLowWatermark(c.Watermark.RefillLowWatermark).
SetRefillHighWatermark(c.Watermark.RefillHighWatermark)
}
// NewBuckets create a new list of buckets.
func (c *BucketizedFieldArrayPoolConfiguration) NewBuckets() []FieldArrayBucket {
buckets := make([]FieldArrayBucket, 0, len(c.Buckets))
for _, bconfig := range c.Buckets {
bucket := bconfig.NewBucket()
buckets = append(buckets, bucket)
}
return buckets
}