feat: starting implementation

This commit is contained in:
2026-04-04 17:29:49 +02:00
parent 7fd2391d6c
commit 895daf6002
3 changed files with 201 additions and 0 deletions

34
options.go Normal file
View File

@@ -0,0 +1,34 @@
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)
}
}