edge/pkg/bundle/zim/option.go

39 lines
631 B
Go
Raw Normal View History

2023-10-11 11:18:32 +02:00
package zim
import "time"
type Options struct {
URLCacheSize int
URLCacheTTL time.Duration
TitleCacheSize int
TitleCacheTTL time.Duration
}
type OptionFunc func(opts *Options)
func NewOptions(funcs ...OptionFunc) *Options {
funcs = append([]OptionFunc{
WithURLCacheSize(64),
WithTitleCacheSize(64),
}, funcs...)
opts := &Options{}
for _, fn := range funcs {
fn(opts)
}
return opts
}
func WithURLCacheSize(size int) OptionFunc {
return func(opts *Options) {
opts.URLCacheSize = size
}
}
func WithTitleCacheSize(size int) OptionFunc {
return func(opts *Options) {
opts.TitleCacheSize = size
}
}