Some checks failed
DCO action / DCO (pull_request) Failing after 2m30s
Tests and linters / Lint (pull_request) Failing after 4m9s
Vulncheck / Vulncheck (pull_request) Successful in 3m51s
Build / Build Components (1.21) (pull_request) Successful in 4m0s
Build / Build Components (1.20) (pull_request) Successful in 4m9s
Tests and linters / Tests (1.20) (pull_request) Successful in 5m17s
Tests and linters / Staticcheck (pull_request) Successful in 5m21s
Tests and linters / Tests (1.21) (pull_request) Successful in 5m56s
Tests and linters / Tests with -race (pull_request) Successful in 6m21s
61 lines
968 B
Go
61 lines
968 B
Go
package pilorama
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
type Option func(*cfg)
|
|
|
|
type cfg struct {
|
|
path string
|
|
perm fs.FileMode
|
|
noSync bool
|
|
maxBatchDelay time.Duration
|
|
maxBatchSize int
|
|
openFile func(string, int, fs.FileMode) (*os.File, error)
|
|
metrics Metrics
|
|
}
|
|
|
|
func WithPath(path string) Option {
|
|
return func(c *cfg) {
|
|
c.path = path
|
|
}
|
|
}
|
|
|
|
func WithPerm(perm fs.FileMode) Option {
|
|
return func(c *cfg) {
|
|
c.perm = perm
|
|
}
|
|
}
|
|
|
|
func WithNoSync(noSync bool) Option {
|
|
return func(c *cfg) {
|
|
c.noSync = true
|
|
}
|
|
}
|
|
|
|
func WithMaxBatchDelay(d time.Duration) Option {
|
|
return func(c *cfg) {
|
|
c.maxBatchDelay = d
|
|
}
|
|
}
|
|
|
|
func WithMaxBatchSize(size int) Option {
|
|
return func(c *cfg) {
|
|
c.maxBatchSize = size
|
|
}
|
|
}
|
|
|
|
func WithOpenFile(openFile func(string, int, fs.FileMode) (*os.File, error)) Option {
|
|
return func(c *cfg) {
|
|
c.openFile = openFile
|
|
}
|
|
}
|
|
|
|
func WithMetrics(m Metrics) Option {
|
|
return func(c *cfg) {
|
|
c.metrics = m
|
|
}
|
|
}
|