Skip to content

Commit

Permalink
addressing comments for not writing docstring for funcs with unexport…
Browse files Browse the repository at this point in the history
…ed types
  • Loading branch information
purnesh42H committed Aug 30, 2024
1 parent bf84b2f commit 18b8820
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 37 deletions.
9 changes: 7 additions & 2 deletions balancer/endpointsharding/endpointsharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 0 additions & 3 deletions credentials/tls/certprovider/pemfile/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/channelz/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
9 changes: 2 additions & 7 deletions internal/channelz/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/testutils/stats/test_metrics_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
8 changes: 0 additions & 8 deletions internal/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 1 addition & 15 deletions mem/buffers.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,20 @@ 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")
}
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")
}
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")
Expand All @@ -166,7 +161,6 @@ func (b *buffer) Free() {
}
}

// Len returns the size of the Buffer.
func (b *buffer) Len() int {
return len(b.ReadOnlyData())
}
Expand Down Expand Up @@ -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()))
}
Expand All @@ -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
}
Expand Down

0 comments on commit 18b8820

Please sign in to comment.