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

Method CreateGroup

pkg/topom/topom_group.go:15–36  ·  view source on GitHub ↗
(gid int)

Source from the content-addressed store, hash-verified

13)
14
15func (s *Topom) CreateGroup(gid int) error {
16 s.mu.Lock()
17 defer s.mu.Unlock()
18 ctx, err := s.newContext()
19 if err != nil {
20 return err
21 }
22
23 if gid <= 0 || gid > models.MaxGroupId {
24 return errors.Errorf("invalid group id = %d, out of range", gid)
25 }
26 if ctx.group[gid] != nil {
27 return errors.Errorf("group-[%d] already exists", gid)
28 }
29 defer s.dirtyGroupCache(gid)
30
31 g := &models.Group{
32 Id: gid,
33 Servers: []*models.GroupServer{},
34 }
35 return s.storeCreateGroup(g)
36}
37
38func (s *Topom) RemoveGroup(gid int) error {
39 s.mu.Lock()

Callers 5

TestGroupCreateFunction · 0.45
TestGroupAddServerFunction · 0.45
TestApiSlotsFunction · 0.45
TestApiGroupFunction · 0.45
handleGroupCommandMethod · 0.45

Calls 4

newContextMethod · 0.95
dirtyGroupCacheMethod · 0.95
storeCreateGroupMethod · 0.95
ErrorfMethod · 0.80

Tested by 4

TestGroupCreateFunction · 0.36
TestGroupAddServerFunction · 0.36
TestApiSlotsFunction · 0.36
TestApiGroupFunction · 0.36