package bloomfilter import ( "errors" "github.com/go-redis/redis/v8" ) type Mode int const ( ModeLocal Mode = iota ModeRedis ) type Options struct { mode Mode client *redis.Client key string } type Option func(*Options) func UseLocal() Option { return func(o *Options) { o.mode = ModeLocal } } func UseRedis(client *redis.Client, key string) Option { return func(o *Options) { o.mode = ModeRedis o.client = client o.key = key } } func (o *Options) repairOption() error { if o.mode == ModeRedis { if o.client == nil || o.key == "" { return errors.New("no addr provided") } } return nil }