Skip to content

Commit 115d220

Browse files
committed
refactor(sharding): simplify group/label function names
Rename for consistency - drop redundant 'Id' suffix since return types already indicate the value type: - labelGroupId → labelGroup - isLabeledGroupId → isLabeledGroup - firstUnlabeledGroupId → firstUnlabeledGroup
1 parent c4e4ccf commit 115d220

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

dgraph/cmd/zero/zero.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,15 @@ func (s *Server) Inform(ctx context.Context, req *pb.TabletRequest) (*pb.TabletR
458458
t.GroupId = 1
459459
case t.Label != "":
460460
// Labeled predicate: route to matching labeled group
461-
gid, err := s.labelGroupId(t.Label)
461+
gid, err := s.labelGroup(t.Label)
462462
if err != nil {
463463
return err
464464
}
465465
glog.Infof("Zero.Inform: labeled predicate %s (label=%q) routed to group %d", t.Predicate, t.Label, gid)
466466
t.GroupId = gid
467-
case s.isLabeledGroupId(t.GroupId):
467+
case s.isLabeledGroup(t.GroupId):
468468
// make sure unlabeled predicates don't go an labeled group
469-
gid, err := s.firstUnlabeledGroupId()
469+
gid, err := s.firstUnlabeledGroup()
470470
if err != nil {
471471
return err
472472
}
@@ -748,16 +748,16 @@ func (s *Server) ShouldServe(
748748
tablet.GroupId = 1
749749
case tablet.Label != "":
750750
// Labeled predicate: route to matching labeled group
751-
gid, err := s.labelGroupId(tablet.Label)
751+
gid, err := s.labelGroup(tablet.Label)
752752
if err != nil {
753753
s.RUnlock()
754754
return nil, err
755755
}
756756
glog.Infof("ShouldServe: labeled predicate %s (label=%q) routed to group %d", tablet.Predicate, tablet.Label, gid)
757757
tablet.GroupId = gid
758-
case s.isLabeledGroupId(tablet.GroupId):
758+
case s.isLabeledGroup(tablet.GroupId):
759759
// Make sure unlabeled predicates don't go to a labeled group
760-
gid, err := s.firstUnlabeledGroupId()
760+
gid, err := s.firstUnlabeledGroup()
761761
if err != nil {
762762
s.RUnlock()
763763
return nil, err
@@ -946,8 +946,8 @@ func (s *Server) getGroupLabel(gid uint32) string {
946946
return s.groupLabel(gid)
947947
}
948948

949-
// labelGroupId the group ID that has the given label, or 0 if none
950-
func (s *Server) labelGroupId(label string) (uint32, error) {
949+
// labelGroup the group ID that has the given label, or 0 if none
950+
func (s *Server) labelGroup(label string) (uint32, error) {
951951
s.AssertRLock()
952952
for gid, group := range s.state.Groups {
953953
for _, member := range group.Members {
@@ -959,16 +959,16 @@ func (s *Server) labelGroupId(label string) (uint32, error) {
959959
return 0, errors.Errorf("No alpha group with label '%s' found", label)
960960
}
961961

962-
// isLabeledGroupId returns true if any member in the group has a label
963-
func (s *Server) isLabeledGroupId(gid uint32) bool {
962+
// isLabeledGroup returns true if any member in the group has a label
963+
func (s *Server) isLabeledGroup(gid uint32) bool {
964964
s.AssertRLock()
965965
return s.groupLabel(gid) != ""
966966
}
967967

968-
func (s *Server) firstUnlabeledGroupId() (uint32, error) {
968+
func (s *Server) firstUnlabeledGroup() (uint32, error) {
969969
s.AssertRLock()
970970
for gid := range s.state.Groups {
971-
if !s.isLabeledGroupId(gid) {
971+
if !s.isLabeledGroup(gid) {
972972
return gid, nil
973973
}
974974
}

0 commit comments

Comments
 (0)