github.com/blend/go-sdk@v1.20220411.3/redis/option.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package redis 9 10 import ( 11 "time" 12 13 "github.com/blend/go-sdk/logger" 14 ) 15 16 // OptConfig sets the redis config. 17 // 18 // Note: this will overwrite any existing settings. 19 func OptConfig(cfg Config) Option { 20 return func(rc *RadixClient) error { 21 rc.Config = cfg 22 return nil 23 } 24 } 25 26 // OptNetwork sets the redis network. 27 func OptNetwork(network string) Option { 28 return func(rc *RadixClient) error { 29 rc.Config.Network = network 30 return nil 31 } 32 } 33 34 // OptAddr sets the redis address. 35 func OptAddr(addr string) Option { 36 return func(rc *RadixClient) error { 37 rc.Config.Addr = addr 38 return nil 39 } 40 } 41 42 // OptAuthUser sets the redis auth user. 43 func OptAuthUser(user string) Option { 44 return func(rc *RadixClient) error { 45 rc.Config.AuthUser = user 46 return nil 47 } 48 } 49 50 // OptAuthPassword sets the redis auth password. 51 func OptAuthPassword(password string) Option { 52 return func(rc *RadixClient) error { 53 rc.Config.AuthPassword = password 54 return nil 55 } 56 } 57 58 // OptDB sets the redis db. 59 func OptDB(db string) Option { 60 return func(rc *RadixClient) error { 61 rc.Config.DB = db 62 return nil 63 } 64 } 65 66 // OptConnectTimeout sets the redis connect timeout. 67 func OptConnectTimeout(connectTimeout time.Duration) Option { 68 return func(rc *RadixClient) error { 69 rc.Config.ConnectTimeout = connectTimeout 70 return nil 71 } 72 } 73 74 // OptTimeout sets the redis general timeout. 75 func OptTimeout(timeout time.Duration) Option { 76 return func(rc *RadixClient) error { 77 rc.Config.Timeout = timeout 78 return nil 79 } 80 } 81 82 // OptLog sets the logger. 83 func OptLog(log logger.Triggerable) Option { 84 return func(rc *RadixClient) error { 85 rc.Log = log 86 return nil 87 } 88 } 89 90 // OptTracer sets the tracer. 91 func OptTracer(tracer Tracer) Option { 92 return func(rc *RadixClient) error { 93 rc.Tracer = tracer 94 return nil 95 } 96 } 97 98 // Option mutates a radix client. 99 type Option func(*RadixClient) error