Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit d92dfcb

Browse files
Merge pull request #1383 from Hellcatlk/go-lint
Fix go-lint warning: "exported method ... should have comment or be unexported"
2 parents 862a6a7 + 92ea5c8 commit d92dfcb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dfget/locator/static_locator.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,51 +82,63 @@ func NewStaticLocatorFromStr(groupName string, nodes []string) (*StaticLocator,
8282
// ----------------------------------------------------------------------------
8383
// implement api methods
8484

85+
// Get returns the current selected supernode, it should be idempotent.
86+
// It should return nil before first calling the Next method.
8587
func (s *StaticLocator) Get() *Supernode {
8688
if s.Group == nil {
8789
return nil
8890
}
8991
return s.Group.GetNode(s.load())
9092
}
9193

94+
// Next chooses the next available supernode for retrying or other
95+
// purpose. The current supernode should be set as this result.
9296
func (s *StaticLocator) Next() *Supernode {
9397
if s.Group == nil || s.load() >= len(s.Group.Nodes) {
9498
return nil
9599
}
96100
return s.Group.GetNode(s.inc())
97101
}
98102

103+
// Select chooses a supernode based on the giving key.
104+
// It should not affect the result of method 'Get()'.
99105
func (s *StaticLocator) Select(key interface{}) *Supernode {
100106
// unnecessary to implement this method
101107
return nil
102108
}
103109

110+
// GetGroup returns the group with the giving name.
104111
func (s *StaticLocator) GetGroup(name string) *SupernodeGroup {
105112
if s.Group == nil || s.Group.Name != name {
106113
return nil
107114
}
108115
return s.Group
109116
}
110117

118+
// All returns all the supernodes.
111119
func (s *StaticLocator) All() []*SupernodeGroup {
112120
if s.Group == nil {
113121
return nil
114122
}
115123
return []*SupernodeGroup{s.Group}
116124
}
117125

126+
// Size returns the number of all supernodes.
118127
func (s *StaticLocator) Size() int {
119128
if s.Group == nil {
120129
return 0
121130
}
122131
return len(s.Group.Nodes)
123132
}
124133

134+
// Report records the metrics of the current supernode in order to choose a
135+
// more appropriate supernode for the next time if necessary.
125136
func (s *StaticLocator) Report(node string, metrics *SupernodeMetrics) {
126137
// unnecessary to implement this method
127138
return
128139
}
129140

141+
// Refresh refreshes all the supernodes.
130142
func (s *StaticLocator) Refresh() bool {
131143
atomic.StoreInt32(&s.idx, -1)
132144
return true

0 commit comments

Comments
 (0)