MCPcopy
hub / github.com/CodisLabs/codis / slotsmgrt

Method slotsmgrt

pkg/proxy/forward.go:137–167  ·  view source on GitHub ↗
(s *Slot, hkey []byte, database int32, seed uint)

Source from the content-addressed store, hash-verified

135}
136
137func (d *forwardHelper) slotsmgrt(s *Slot, hkey []byte, database int32, seed uint) error {
138 m := &Request{}
139 m.Multi = []*redis.Resp{
140 redis.NewBulkBytes([]byte("SLOTSMGRTTAGONE")),
141 redis.NewBulkBytes(s.backend.bc.host),
142 redis.NewBulkBytes(s.backend.bc.port),
143 redis.NewBulkBytes([]byte("3000")),
144 redis.NewBulkBytes(hkey),
145 }
146 m.Batch = &sync.WaitGroup{}
147
148 s.migrate.bc.BackendConn(database, seed, true).PushBack(m)
149
150 m.Batch.Wait()
151
152 if err := m.Err; err != nil {
153 return err
154 }
155 switch resp := m.Resp; {
156 case resp == nil:
157 return ErrRespIsRequired
158 case resp.IsError():
159 return fmt.Errorf("bad slotsmgrt resp: %s", resp.Value)
160 case resp.IsInt():
161 log.Debugf("slot-%04d migrate from %s to %s: hash key = %s, database = %d, resp = %s",
162 s.id, s.migrate.bc.Addr(), s.backend.bc.Addr(), hkey, database, resp.Value)
163 return nil
164 default:
165 return fmt.Errorf("bad slotsmgrt resp: should be integer, but got %s", resp.Type)
166 }
167}
168
169func (d *forwardHelper) slotsmgrtExecWrapper(s *Slot, hkey []byte, database int32, seed uint, multi []*redis.Resp) (_ *redis.Resp, moved bool, _ error) {
170 m := &Request{}

Callers 1

processMethod · 0.80

Calls 8

BackendConnMethod · 0.80
IsErrorMethod · 0.80
ErrorfMethod · 0.80
IsIntMethod · 0.80
DebugfMethod · 0.80
PushBackMethod · 0.45
WaitMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected