package director import ( "time" "forge.cadoles.com/cadoles/bouncer/internal/cache" "forge.cadoles.com/cadoles/bouncer/internal/cache/memory" "forge.cadoles.com/cadoles/bouncer/internal/cache/ttl" "forge.cadoles.com/cadoles/bouncer/internal/store" ) type Options struct { Layers []Layer ProxyCache cache.Cache[string, []*store.Proxy] LayerCache cache.Cache[string, []*store.Layer] } type OptionFunc func(opts *Options) func NewOptions(funcs ...OptionFunc) *Options { opts := &Options{ Layers: make([]Layer, 0), ProxyCache: ttl.NewCache( memory.NewCache[string, []*store.Proxy](), memory.NewCache[string, time.Time](), 30*time.Second, ), LayerCache: ttl.NewCache( memory.NewCache[string, []*store.Layer](), memory.NewCache[string, time.Time](), 30*time.Second, ), } for _, fn := range funcs { fn(opts) } return opts } func WithLayers(layers ...Layer) OptionFunc { return func(opts *Options) { opts.Layers = layers } } func WithProxyCache(cache cache.Cache[string, []*store.Proxy]) OptionFunc { return func(opts *Options) { opts.ProxyCache = cache } } func WithLayerCache(cache cache.Cache[string, []*store.Layer]) OptionFunc { return func(opts *Options) { opts.LayerCache = cache } }