MCPcopy
hub / github.com/redis/go-redis / init

Method init

ring.go:168–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166}
167
168func (opt *RingOptions) init() {
169 if opt.NewClient == nil {
170 opt.NewClient = func(opt *Options) *Client {
171 return NewClient(opt)
172 }
173 }
174
175 if opt.HeartbeatFrequency == 0 {
176 opt.HeartbeatFrequency = 500 * time.Millisecond
177 }
178
179 if opt.HeartbeatFn == nil {
180 opt.HeartbeatFn = defaultHeartbeatFn
181 }
182
183 if opt.NewConsistentHash == nil {
184 opt.NewConsistentHash = newRendezvous
185 }
186
187 switch opt.MaxRetries {
188 case -1:
189 opt.MaxRetries = 0
190 case 0:
191 opt.MaxRetries = 3
192 }
193 switch opt.MinRetryBackoff {
194 case -1:
195 opt.MinRetryBackoff = 0
196 case 0:
197 opt.MinRetryBackoff = 8 * time.Millisecond
198 }
199 switch opt.MaxRetryBackoff {
200 case -1:
201 opt.MaxRetryBackoff = 0
202 case 0:
203 opt.MaxRetryBackoff = 512 * time.Millisecond
204 }
205
206 if opt.ReadBufferSize == 0 {
207 opt.ReadBufferSize = proto.DefaultBufferSize
208 }
209 if opt.WriteBufferSize == 0 {
210 opt.WriteBufferSize = proto.DefaultBufferSize
211 }
212}
213
214func (opt *RingOptions) clientOptions() *Options {
215 return &Options{

Callers 1

NewRingFunction · 0.45

Calls 1

NewClientFunction · 0.85

Tested by

no test coverage detected