package logotel import "git.blauwelle.com/go/crate/synchelper" func newConfig(opts ...Option) *config { cfg := defaultConfig() for _, opt := range opts { opt.apply(cfg) } if !cfg.hasPool { cfg.bufferPool = synchelper.NewBytesBufferPool(512, 4096) } return cfg } func defaultConfig() *config { return &config{ hasPool: false, } } // WithBufferPool 指定缓冲池 func WithBufferPool(pool synchelper.BytesBufferPool) Option { return optionFunc(func(cfg *config) { cfg.bufferPool = pool cfg.hasPool = true }) } // Option 配置 Processor type Option interface { apply(cfg *config) } type config struct { bufferPool synchelper.BytesBufferPool hasPool bool } type optionFunc func(cfg *config) func (fn optionFunc) apply(cfg *config) { fn(cfg) }