fixup lint
Some checks failed
build / lint (push) Successful in 29s
build / test (push) Failing after 37s
codeql / analyze (go) (push) Failing after 7m23s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-12-15 22:09:59 +03:00
parent c8d21b4ef4
commit 21d40b8e69

View File

@ -22,11 +22,7 @@ func (r *Store) Connect(ctx context.Context) error {
} }
func (r *Store) Init(opts ...options.Option) error { func (r *Store) Init(opts ...options.Option) error {
for _, o := range opts { return r.configure(opts...)
o(&r.opts)
}
return r.configure()
} }
func (r *Store) Redis() redis.UniversalClient { func (r *Store) Redis() redis.UniversalClient {
@ -237,8 +233,11 @@ func (r *Store) MWrite(ctx context.Context, keys []string, vals []interface{}, o
} }
cmds, err := r.cli.Pipelined(ctx, func(pipe redis.Pipeliner) error { cmds, err := r.cli.Pipelined(ctx, func(pipe redis.Pipeliner) error {
var err error
for idx := 0; idx < len(kvs); idx += 2 { for idx := 0; idx < len(kvs); idx += 2 {
pipe.Set(ctx, kvs[idx], kvs[idx+1], options.TTL).Result() if _, err = pipe.Set(ctx, kvs[idx], kvs[idx+1], options.TTL).Result(); err != nil {
return err
}
} }
return nil return nil
}) })
@ -335,13 +334,20 @@ func NewStore(opts ...options.Option) *Store {
return &Store{opts: store.NewOptions(opts...)} return &Store{opts: store.NewOptions(opts...)}
} }
func (r *Store) configure() error { func (r *Store) configure(opts ...options.Option) error {
var redisUniversalOptions *redis.UniversalOptions if r.cli != nil && len(opts) == 0 {
if r.cli != nil && r.opts.Context == nil {
return nil return nil
} }
var redisUniversalOptions *redis.UniversalOptions
var err error
for _, o := range opts {
if err = o(r.opts); err != nil {
return err
}
}
if r.opts.Context != nil { if r.opts.Context != nil {
if c, ok := r.opts.Context.Value(universalConfigKey{}).(*redis.UniversalOptions); ok { if c, ok := r.opts.Context.Value(universalConfigKey{}).(*redis.UniversalOptions); ok {
redisUniversalOptions = c redisUniversalOptions = c