Skip to content

Commit 04e78b0

Browse files
authored
.*: fix lint issues of not having comments for exported funcs and vars along with any remaining issues and enable remaining disabled rules (#7575)
* .*: fix lint issues of not having comments for exported funcs and vars along with any remaining issues and enable remaining disabled rules
1 parent 31ffeee commit 04e78b0

File tree

20 files changed

+141
-22
lines changed

20 files changed

+141
-22
lines changed

balancer/endpointsharding/endpointsharding.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ func (bw *balancerWrapper) UpdateState(state balancer.State) {
285285
bw.es.updateState()
286286
}
287287

288+
// ParseConfig parses a child config list and returns an LB config to use with
289+
// the endpointsharding balancer.
290+
//
291+
// cfg is expected to be a JSON array of LB policy names + configs as the
292+
// format of the loadBalancingConfig field in ServiceConfig.
288293
func ParseConfig(cfg json.RawMessage) (serviceconfig.LoadBalancingConfig, error) {
289294
return gracefulswitch.ParseConfig(cfg)
290295
}

balancer/pickfirst/pickfirst.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ func (b *pickfirstBalancer) ResolverError(err error) {
103103
})
104104
}
105105

106+
// Shuffler is an interface for shuffling an address list.
106107
type Shuffler interface {
107108
ShuffleAddressListForTesting(n int, swap func(i, j int))
108109
}
109110

111+
// ShuffleAddressListForTesting pseudo-randomizes the order of addresses. n
112+
// is the number of elements. swap swaps the elements with indexes i and j.
110113
func ShuffleAddressListForTesting(n int, swap func(i, j int)) { rand.Shuffle(n, swap) }
111114

112115
func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState) error {

credentials/tls/certprovider/pemfile/builder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
)
3030

3131
const (
32+
// PluginName is the name of the PEM file watcher plugin.
3233
PluginName = "file_watcher"
3334
defaultRefreshInterval = 10 * time.Minute
3435
)

examples/features/advancedtls/client/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*
1717
*/
1818

19+
// Binary client is an example client demonstrating use of advancedtls, to set
20+
// up a secure gRPC client connection with various TLS authentication methods.
1921
package main
2022

2123
import (

examples/features/advancedtls/server/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*
1717
*/
1818

19+
// Binary server is an example client demonstrating how to set up a secure gRPC
20+
// server using advancedtls.
1921
package main
2022

2123
import (

internal/balancer/gracefulswitch/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type lbConfig struct {
3333
childConfig serviceconfig.LoadBalancingConfig
3434
}
3535

36+
// ChildName returns the name of the child balancer of the gracefulswitch
37+
// Balancer.
3638
func ChildName(l serviceconfig.LoadBalancingConfig) string {
3739
return l.(*lbConfig).childBuilder.Name()
3840
}

internal/channelz/channel.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ type Channel struct {
4343
// Non-zero traceRefCount means the trace of this channel cannot be deleted.
4444
traceRefCount int32
4545

46+
// ChannelMetrics holds connectivity state, target and call metrics for the
47+
// channel within channelz.
4648
ChannelMetrics ChannelMetrics
4749
}
4850

4951
// Implemented to make Channel implement the Identifier interface used for
5052
// nesting.
5153
func (c *Channel) channelzIdentifier() {}
5254

55+
// String returns a string representation of the Channel, including its parent
56+
// entity and ID.
5357
func (c *Channel) String() string {
5458
if c.Parent == nil {
5559
return fmt.Sprintf("Channel #%d", c.ID)
@@ -61,24 +65,31 @@ func (c *Channel) id() int64 {
6165
return c.ID
6266
}
6367

68+
// SubChans returns a copy of the map of sub-channels associated with the
69+
// Channel.
6470
func (c *Channel) SubChans() map[int64]string {
6571
db.mu.RLock()
6672
defer db.mu.RUnlock()
6773
return copyMap(c.subChans)
6874
}
6975

76+
// NestedChans returns a copy of the map of nested channels associated with the
77+
// Channel.
7078
func (c *Channel) NestedChans() map[int64]string {
7179
db.mu.RLock()
7280
defer db.mu.RUnlock()
7381
return copyMap(c.nestedChans)
7482
}
7583

84+
// Trace returns a copy of the Channel's trace data.
7685
func (c *Channel) Trace() *ChannelTrace {
7786
db.mu.RLock()
7887
defer db.mu.RUnlock()
7988
return c.trace.copy()
8089
}
8190

91+
// ChannelMetrics holds connectivity state, target and call metrics for the
92+
// channel within channelz.
8293
type ChannelMetrics struct {
8394
// The current connectivity state of the channel.
8495
State atomic.Pointer[connectivity.State]
@@ -136,12 +147,16 @@ func strFromPointer(s *string) string {
136147
return *s
137148
}
138149

150+
// String returns a string representation of the ChannelMetrics, including its
151+
// state, target, and call metrics.
139152
func (c *ChannelMetrics) String() string {
140153
return fmt.Sprintf("State: %v, Target: %s, CallsStarted: %v, CallsSucceeded: %v, CallsFailed: %v, LastCallStartedTimestamp: %v",
141154
c.State.Load(), strFromPointer(c.Target.Load()), c.CallsStarted.Load(), c.CallsSucceeded.Load(), c.CallsFailed.Load(), c.LastCallStartedTimestamp.Load(),
142155
)
143156
}
144157

158+
// NewChannelMetricForTesting creates a new instance of ChannelMetrics with
159+
// specified initial values for testing purposes.
145160
func NewChannelMetricForTesting(state connectivity.State, target string, started, succeeded, failed, timestamp int64) *ChannelMetrics {
146161
c := &ChannelMetrics{}
147162
c.State.Store(&state)

internal/channelz/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func NewServerMetricsForTesting(started, succeeded, failed, timestamp int64) *Se
5959
return sm
6060
}
6161

62+
// CopyFrom copies the metrics data from the provided ServerMetrics
63+
// instance into the current instance.
6264
func (sm *ServerMetrics) CopyFrom(o *ServerMetrics) {
6365
sm.CallsStarted.Store(o.CallsStarted.Load())
6466
sm.CallsSucceeded.Store(o.CallsSucceeded.Load())

internal/channelz/socket.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,18 @@ type EphemeralSocketMetrics struct {
7070
RemoteFlowControlWindow int64
7171
}
7272

73+
// SocketType represents the type of socket.
7374
type SocketType string
7475

76+
// SocketType can be one of these.
7577
const (
7678
SocketTypeNormal = "NormalSocket"
7779
SocketTypeListen = "ListenSocket"
7880
)
7981

82+
// Socket represents a socket within channelz which includes socket
83+
// metrics and data related to socket activity and provides methods
84+
// for managing and interacting with sockets.
8085
type Socket struct {
8186
Entity
8287
SocketType SocketType
@@ -100,6 +105,8 @@ type Socket struct {
100105
Security credentials.ChannelzSecurityValue
101106
}
102107

108+
// String returns a string representation of the Socket, including its parent
109+
// entity, socket type, and ID.
103110
func (ls *Socket) String() string {
104111
return fmt.Sprintf("%s %s #%d", ls.Parent, ls.SocketType, ls.ID)
105112
}

internal/channelz/subchannel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ func (sc *SubChannel) id() int64 {
4747
return sc.ID
4848
}
4949

50+
// Sockets returns a copy of the sockets map associated with the SubChannel.
5051
func (sc *SubChannel) Sockets() map[int64]string {
5152
db.mu.RLock()
5253
defer db.mu.RUnlock()
5354
return copyMap(sc.sockets)
5455
}
5556

57+
// Trace returns a copy of the ChannelTrace associated with the SubChannel.
5658
func (sc *SubChannel) Trace() *ChannelTrace {
5759
db.mu.RLock()
5860
defer db.mu.RUnlock()

internal/channelz/trace.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,21 @@ type TraceEvent struct {
7979
Parent *TraceEvent
8080
}
8181

82+
// ChannelTrace provides tracing information for a channel.
83+
// It tracks various events and metadata related to the channel's lifecycle
84+
// and operations.
8285
type ChannelTrace struct {
83-
cm *channelMap
84-
clearCalled bool
86+
cm *channelMap
87+
clearCalled bool
88+
// The time when the trace was created.
8589
CreationTime time.Time
86-
EventNum int64
87-
mu sync.Mutex
88-
Events []*traceEvent
90+
// A counter for the number of events recorded in the
91+
// trace.
92+
EventNum int64
93+
mu sync.Mutex
94+
// A slice of traceEvent pointers representing the events recorded for
95+
// this channel.
96+
Events []*traceEvent
8997
}
9098

9199
func (c *ChannelTrace) copy() *ChannelTrace {
@@ -175,6 +183,7 @@ var refChannelTypeToString = map[RefChannelType]string{
175183
RefNormalSocket: "NormalSocket",
176184
}
177185

186+
// String returns a string representation of the RefChannelType
178187
func (r RefChannelType) String() string {
179188
return refChannelTypeToString[r]
180189
}

internal/idle/idle.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ func (m *Manager) tryEnterIdleMode() bool {
182182
return true
183183
}
184184

185+
// EnterIdleModeForTesting instructs the channel to enter idle mode.
185186
func (m *Manager) EnterIdleModeForTesting() {
186187
m.tryEnterIdleMode()
187188
}
@@ -266,6 +267,7 @@ func (m *Manager) isClosed() bool {
266267
return atomic.LoadInt32(&m.closed) == 1
267268
}
268269

270+
// Close stops the timer associated with the Manager, if it exists.
269271
func (m *Manager) Close() {
270272
atomic.StoreInt32(&m.closed, 1)
271273

internal/internal.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ var (
191191
// ExitIdleModeForTesting gets the ClientConn to exit IDLE mode.
192192
ExitIdleModeForTesting any // func(*grpc.ClientConn) error
193193

194+
// ChannelzTurnOffForTesting disables the Channelz service for testing
195+
// purposes.
194196
ChannelzTurnOffForTesting func()
195197

196198
// TriggerXDSResourceNotFoundForTesting causes the provided xDS Client to

internal/stats/metrics_recorder_list.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ func verifyLabels(desc *estats.MetricDescriptor, labelsRecv ...string) {
5454
}
5555
}
5656

57+
// RecordInt64Count records the measurement alongside labels on the int
58+
// count associated with the provided handle.
5759
func (l *MetricsRecorderList) RecordInt64Count(handle *estats.Int64CountHandle, incr int64, labels ...string) {
5860
verifyLabels(handle.Descriptor(), labels...)
5961

@@ -62,6 +64,8 @@ func (l *MetricsRecorderList) RecordInt64Count(handle *estats.Int64CountHandle,
6264
}
6365
}
6466

67+
// RecordFloat64Count records the measurement alongside labels on the float
68+
// count associated with the provided handle.
6569
func (l *MetricsRecorderList) RecordFloat64Count(handle *estats.Float64CountHandle, incr float64, labels ...string) {
6670
verifyLabels(handle.Descriptor(), labels...)
6771

@@ -70,6 +74,8 @@ func (l *MetricsRecorderList) RecordFloat64Count(handle *estats.Float64CountHand
7074
}
7175
}
7276

77+
// RecordInt64Histo records the measurement alongside labels on the int
78+
// histo associated with the provided handle.
7379
func (l *MetricsRecorderList) RecordInt64Histo(handle *estats.Int64HistoHandle, incr int64, labels ...string) {
7480
verifyLabels(handle.Descriptor(), labels...)
7581

@@ -78,6 +84,8 @@ func (l *MetricsRecorderList) RecordInt64Histo(handle *estats.Int64HistoHandle,
7884
}
7985
}
8086

87+
// RecordFloat64Histo records the measurement alongside labels on the float
88+
// histo associated with the provided handle.
8189
func (l *MetricsRecorderList) RecordFloat64Histo(handle *estats.Float64HistoHandle, incr float64, labels ...string) {
8290
verifyLabels(handle.Descriptor(), labels...)
8391

@@ -86,6 +94,8 @@ func (l *MetricsRecorderList) RecordFloat64Histo(handle *estats.Float64HistoHand
8694
}
8795
}
8896

97+
// RecordInt64Gauge records the measurement alongside labels on the int
98+
// gauge associated with the provided handle.
8999
func (l *MetricsRecorderList) RecordInt64Gauge(handle *estats.Int64GaugeHandle, incr int64, labels ...string) {
90100
verifyLabels(handle.Descriptor(), labels...)
91101

0 commit comments

Comments
 (0)