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

Method verifyAuth

pkg/proxy/backend.go:183–210  ·  view source on GitHub ↗
(c *redis.Conn, auth string)

Source from the content-addressed store, hash-verified

181}
182
183func (bc *BackendConn) verifyAuth(c *redis.Conn, auth string) error {
184 if auth == "" {
185 return nil
186 }
187
188 multi := []*redis.Resp{
189 redis.NewBulkBytes([]byte("AUTH")),
190 redis.NewBulkBytes([]byte(auth)),
191 }
192
193 if err := c.EncodeMultiBulk(multi, true); err != nil {
194 return err
195 }
196
197 resp, err := c.Decode()
198 switch {
199 case err != nil:
200 return err
201 case resp == nil:
202 return ErrRespIsRequired
203 case resp.IsError():
204 return fmt.Errorf("error resp: %s", resp.Value)
205 case resp.IsString():
206 return nil
207 default:
208 return fmt.Errorf("error resp: should be string, but got %s", resp.Type)
209 }
210}
211
212func (bc *BackendConn) selectDatabase(c *redis.Conn, database int) error {
213 if database == 0 {

Callers 1

newBackendReaderMethod · 0.95

Calls 5

DecodeMethod · 0.80
IsErrorMethod · 0.80
ErrorfMethod · 0.80
IsStringMethod · 0.80
EncodeMultiBulkMethod · 0.45

Tested by

no test coverage detected