Skip to content
Open
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
9 changes: 9 additions & 0 deletions pkg/ddc/base/portallocator/random_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ func (r *RandomAllocator) Allocate(port int) error {

}

// Release releases the resource associated with the given index.
// For the RandomAllocator, no actual resource is allocated per index,
// so this method does nothing and always returns a nil error.
//
// Parameters:
// - i: the index of the resource to release (unused).
//
// Returns:
// - error: always nil, indicating success with no action.
Comment on lines +57 to +65
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

The terminology used in the documentation is slightly misleading. In the context of a port allocator, the parameter i represents a port number, not an index. Using "index" might lead a developer to believe they should pass a 0-based position (e.g., from a slice of allocated ports) rather than the port value itself.

Additionally, to maintain consistency with other documented methods in this package (such as AllocateBatch in bitmap_allocator.go), it is recommended to include the type in the parameter description and use consistent capitalization.

Suggested change
// Release releases the resource associated with the given index.
// For the RandomAllocator, no actual resource is allocated per index,
// so this method does nothing and always returns a nil error.
//
// Parameters:
// - i: the index of the resource to release (unused).
//
// Returns:
// - error: always nil, indicating success with no action.
// Release releases the resource associated with the given port.
// For the RandomAllocator, port allocations are not tracked,
// so this method does nothing and always returns a nil error.
//
// Parameters:
// - i (int): The port to release (unused).
//
// Returns:
// - error: Always nil, indicating success with no action.

func (r *RandomAllocator) Release(i int) error {
// no need to release
return nil
Expand Down
Loading