MCPcopy Index your code
hub / github.com/CodisLabs/codis / newBackendReader

Method newBackendReader

pkg/proxy/backend.go:157–181  ·  view source on GitHub ↗
(round int, config *Config)

Source from the content-addressed store, hash-verified

155}
156
157func (bc *BackendConn) newBackendReader(round int, config *Config) (*redis.Conn, chan<- *Request, error) {
158 c, err := redis.DialTimeout(bc.addr, time.Second*5,
159 config.BackendRecvBufsize.AsInt(),
160 config.BackendSendBufsize.AsInt())
161 if err != nil {
162 return nil, nil, err
163 }
164 c.ReaderTimeout = config.BackendRecvTimeout.Duration()
165 c.WriterTimeout = config.BackendSendTimeout.Duration()
166 c.SetKeepAlivePeriod(config.BackendKeepAlivePeriod.Duration())
167
168 if err := bc.verifyAuth(c, config.ProductAuth); err != nil {
169 c.Close()
170 return nil, nil, err
171 }
172 if err := bc.selectDatabase(c, bc.database); err != nil {
173 c.Close()
174 return nil, nil, err
175 }
176
177 tasks := make(chan *Request, config.BackendMaxPipeline)
178 go bc.loopReader(tasks, c, round)
179
180 return c, tasks, nil
181}
182
183func (bc *BackendConn) verifyAuth(c *redis.Conn, auth string) error {
184 if auth == "" {

Callers 1

loopWriterMethod · 0.95

Calls 7

verifyAuthMethod · 0.95
selectDatabaseMethod · 0.95
loopReaderMethod · 0.95
DurationMethod · 0.80
SetKeepAlivePeriodMethod · 0.80
CloseMethod · 0.65
AsIntMethod · 0.45

Tested by

no test coverage detected