From 18b8820ba4b16d0ddaae75d199898ecaaad66651 Mon Sep 17 00:00:00 2001 From: Purnesh Dixit Date: Fri, 30 Aug 2024 23:46:48 +0530 Subject: [PATCH] addressing comments for not writing docstring for funcs with unexported types --- balancer/endpointsharding/endpointsharding.go | 9 +++++++-- credentials/tls/certprovider/pemfile/builder.go | 3 --- internal/channelz/server.go | 2 +- internal/channelz/socket.go | 9 ++------- .../testutils/stats/test_metrics_recorder.go | 2 +- internal/transport/transport.go | 8 -------- mem/buffers.go | 16 +--------------- 7 files changed, 12 insertions(+), 37 deletions(-) diff --git a/balancer/endpointsharding/endpointsharding.go b/balancer/endpointsharding/endpointsharding.go index cd04700c4888..031a28c845ef 100644 --- a/balancer/endpointsharding/endpointsharding.go +++ b/balancer/endpointsharding/endpointsharding.go @@ -285,8 +285,13 @@ func (bw *balancerWrapper) UpdateState(state balancer.State) { bw.es.updateState() } -// ParseConfig parses a child config list and returns a LB config for the -// gracefulswitch Balancer. +// ParseConfig parses a child config list and returns a LB to use with the +// endpointsharding balancer. +// +// cfg is expected to be a json.RawMessage containing a JSON array of LB policy +// names + configs as the format of the "loadBalancingConfig" field in +// ServiceConfig. It returns a type that should be passed to +// UpdateClientConnState in the BalancerConfig field. func ParseConfig(cfg json.RawMessage) (serviceconfig.LoadBalancingConfig, error) { return gracefulswitch.ParseConfig(cfg) } diff --git a/credentials/tls/certprovider/pemfile/builder.go b/credentials/tls/certprovider/pemfile/builder.go index 144ef77b3670..ad4207892b7e 100644 --- a/credentials/tls/certprovider/pemfile/builder.go +++ b/credentials/tls/certprovider/pemfile/builder.go @@ -40,8 +40,6 @@ func init() { type pluginBuilder struct{} -// ParseConfig parses the configuration data from JSON and returns a -// certprovider.BuildableConfig for the PEM file watcher. func (p *pluginBuilder) ParseConfig(c any) (*certprovider.BuildableConfig, error) { data, ok := c.(json.RawMessage) if !ok { @@ -56,7 +54,6 @@ func (p *pluginBuilder) ParseConfig(c any) (*certprovider.BuildableConfig, error }), nil } -// Name returns the name of the PEM file watcher plugin. func (p *pluginBuilder) Name() string { return PluginName } diff --git a/internal/channelz/server.go b/internal/channelz/server.go index 8b06970cd215..b5a82499299d 100644 --- a/internal/channelz/server.go +++ b/internal/channelz/server.go @@ -59,7 +59,7 @@ func NewServerMetricsForTesting(started, succeeded, failed, timestamp int64) *Se return sm } -// CopyFrom copies the metrics data from provided ServerMetrics +// CopyFrom copies the metrics data from the provided ServerMetrics // instance into the current instance. func (sm *ServerMetrics) CopyFrom(o *ServerMetrics) { sm.CallsStarted.Store(o.CallsStarted.Load()) diff --git a/internal/channelz/socket.go b/internal/channelz/socket.go index 8e6fac58c160..90103847c5f3 100644 --- a/internal/channelz/socket.go +++ b/internal/channelz/socket.go @@ -70,17 +70,12 @@ type EphemeralSocketMetrics struct { RemoteFlowControlWindow int64 } -// SocketType represents the type of socket, indicating whether it is a -// NormalSocket or a ListenSocket. +// SocketType represents the type of socket. type SocketType string +// SocketType can be one of these. const ( - // SocketTypeNormal represents a standard socket used for normal - // operations. SocketTypeNormal = "NormalSocket" - - // SocketTypeListen represents a socket used specifically for - // listening for incoming connections. SocketTypeListen = "ListenSocket" ) diff --git a/internal/testutils/stats/test_metrics_recorder.go b/internal/testutils/stats/test_metrics_recorder.go index 7c112643a4f4..ae53002065ec 100644 --- a/internal/testutils/stats/test_metrics_recorder.go +++ b/internal/testutils/stats/test_metrics_recorder.go @@ -290,5 +290,5 @@ func (r *NoopMetricsRecorder) RecordInt64Histo(*estats.Int64HistoHandle, int64, // RecordFloat64Histo is noop implementation of RecordFloat64Histo. func (r *NoopMetricsRecorder) RecordFloat64Histo(*estats.Float64HistoHandle, float64, ...string) {} -// RecordInt64Gauge is moop implementation of RecordInt64Gauge. +// RecordInt64Gauge is noop implementation of RecordInt64Gauge. func (r *NoopMetricsRecorder) RecordInt64Gauge(*estats.Int64GaugeHandle, int64, ...string) {} diff --git a/internal/transport/transport.go b/internal/transport/transport.go index e7cfdd135d0a..9a3bb3a63eae 100644 --- a/internal/transport/transport.go +++ b/internal/transport/transport.go @@ -133,14 +133,6 @@ type recvBufferReader struct { err error } -// ReadHeader reads data into the provided header slice. It first checks if -// there is an existing error and returns it immediately if present. If -// there is data remaining from the previous call, it uses `mem.ReadUnsafe` -// to copy the data into the header slice and returns the number of bytes read. -// If there is no previous data, it determines whether to call -// `readHeaderClient` or `readHeader` based on the presence of `closeStream`. -// The method returns the number of bytes read and any error encountered during -// the operation. func (r *recvBufferReader) ReadHeader(header []byte) (n int, err error) { if r.err != nil { return 0, r.err diff --git a/mem/buffers.go b/mem/buffers.go index ed8380c2f43d..5706eff85232 100644 --- a/mem/buffers.go +++ b/mem/buffers.go @@ -122,7 +122,6 @@ func Copy(data []byte, pool BufferPool) Buffer { return NewBuffer(buf, pool) } -// ReadOnlyData returns the underlying byte slice of the Buffer. func (b *buffer) ReadOnlyData() []byte { if b.refs == nil { panic("Cannot read freed buffer") @@ -130,8 +129,6 @@ func (b *buffer) ReadOnlyData() []byte { return b.data } -// Ref increments the reference counter of the Buffer, indicating that an -// additional reference to the Buffer has been acquired. func (b *buffer) Ref() { if b.refs == nil { panic("Cannot ref freed buffer") @@ -139,8 +136,6 @@ func (b *buffer) Ref() { b.refs.Add(1) } -// Free decrements the reference counter of the Buffer and releases the -// underlying byte slice if the counter reaches 0. func (b *buffer) Free() { if b.refs == nil { panic("Cannot free freed buffer") @@ -166,7 +161,6 @@ func (b *buffer) Free() { } } -// Len returns the size of the Buffer. func (b *buffer) Len() int { return len(b.ReadOnlyData()) } @@ -203,8 +197,6 @@ func (b *buffer) read(buf []byte) (int, Buffer) { return n, b } -// String returns a string representation of the buffer. May be used for -// debugging purposes. func (b *buffer) String() string { return fmt.Sprintf("mem.Buffer(%p, data: %p, length: %d)", b, b.ReadOnlyData(), len(b.ReadOnlyData())) } @@ -226,18 +218,12 @@ func SplitUnsafe(buf Buffer, n int) (left, right Buffer) { // methods are no-op implementations. type emptyBuffer struct{} -// Noop implementation of ReadOnlyData func (e emptyBuffer) ReadOnlyData() []byte { return nil } - -// Ref is noop implementation of Ref. -func (e emptyBuffer) Ref() {} - -// Free is noop implementation of Free. +func (e emptyBuffer) Ref() {} func (e emptyBuffer) Free() {} -// Len is noop implementation of Len. func (e emptyBuffer) Len() int { return 0 }