Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/ddc/base/portallocator/bitmap_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func (b *BitMapAllocator) needResetReservedPorts() bool {
return true
}

// newBitMapAllocator creates a bitmap-based port allocator for the given port range.
// It initializes the underlying allocator and returns a BitMapAllocator instance.
// It returns an error if the allocator cannot be created.
Comment on lines +38 to +40
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This comment is a bit verbose and contains some repetition. For better readability and adherence to Go's idiomatic documentation style (as described in Effective Go), it could be made more concise.

Specifically:

  • The phrases creates a bitmap-based port allocator and returns a BitMapAllocator instance are redundant.
  • Mentioning that it initializes the underlying allocator is an implementation detail that can be omitted.

A single-line comment would be more idiomatic here.

Suggested change
// newBitMapAllocator creates a bitmap-based port allocator for the given port range.
// It initializes the underlying allocator and returns a BitMapAllocator instance.
// It returns an error if the allocator cannot be created.
// newBitMapAllocator creates a new BitMapAllocator for the given port range, returning an error if creation fails.

func newBitMapAllocator(pr *net.PortRange, log logr.Logger) (BatchAllocatorInterface, error) {
// TODO passing offset value.
alloc, err := portallocator.New(*pr, func(max int, rangeSpec string, offset int) (allocator.Interface, error) {
Expand Down
Loading