Alejandro Lopez
341fe1688f
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
This aims to reduce the usage of chmod hackery to induce or simulate OS-related failures. Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
54 lines
865 B
Go
54 lines
865 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)
|
|
}
|
|
|
|
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 = noSync
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|