package ring import "fmt" const DefaultGrowthFactor = 2 const DefaultCapacity = 16 type config struct { capacity uint64 growthFactor uint64 } type Option func(*config) func GrowthFactor(value int) Option { if value <= 1 { panic(fmt.Errorf("go-ring: growth factor must be greater than 1, got %d", value)) } return func(c *config) { c.growthFactor = uint64(value) } } func Capacity(value int) Option { if value < 0 { panic(fmt.Errorf("go-ring: starting capacity must be non-negative, got %d", value)) } return func(c *config) { c.capacity = uint64(value) } }