Skip to content

go fix, and modernize some code - #73

Merged
vvoland merged 5 commits into
docker:mainfrom
thaJeztah:go_modernize
Aug 28, 2026
Merged

go fix, and modernize some code#73
vvoland merged 5 commits into
docker:mainfrom
thaJeztah:go_modernize

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

go fix, and modernize some code

automated fixes from; go fix -mod=readonly -all ./...

rename/remove intermediate vars that shadowed

Also move the backoff var closer to where used

switch to math/rand/v2

avoid chainging logrus.WithField

refactor: avoid redundant sink lookup when broadcasting

Remove closed sinks directly by index while iterating over the broadcaster's
sink slice. This avoids searching the slice again for every closed sink and
prevents skipping entries when removing elements during iteration.

Use slices.Index and slices.Delete for explicit sink removals, replacing the
local remove helper and manual slice manipulation.

automated fixes from; `go fix -mod=readonly -all ./...`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Also move the backoff var closer to where used

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Remove closed sinks directly by index while iterating over the broadcaster's
sink slice. This avoids searching the slice again for every closed sink and
prevents skipping entries when removing elements during iteration.

Use slices.Index and slices.Delete for explicit sink removals, replacing the
local remove helper and manual slice manipulation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR applies go fix-driven modernization across the events package, updating APIs and idioms (notably math/rand/v2, sync/atomic typed atomics, and slices helpers) and refining broadcaster behavior to remove closed sinks safely during iteration.

Changes:

  • Modernize Go code and types (e.g., any, typed atomics, min, integer range loops) and update randomness usage to math/rand/v2.
  • Refactor Broadcaster.run to delete closed sinks in-place during iteration, and use slices.Contains/Index/Delete for clearer sink management.
  • Simplify String() implementations and adjust structured logging usage to avoid mutating logrus entries via chained WithField calls.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
retry.go Switch to math/rand/v2, use typed atomic.Uint64, avoid logger shadowing, and minor cleanup/modernization.
retry_test.go Modernize loops and simplify expected backoff calculation with min().
queue.go Add clarifying comment about Front() non-nil under the lock.
filter_test.go Modernize integer loop to for i := range nevents.
event.go Replace interface{} with any for Event.
common_test.go Switch to math/rand/v2 and modernize variadic arg types to ...any.
channel.go Simplify String() by directly sprinting a map[string]any.
broadcast.go Use slices helpers; fix sink removal during iteration; adjust logrus field usage; simplify String().
broadcast_test.go Modernize integer loops in tests/benchmarks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vvoland
vvoland merged commit 1691d3a into docker:main Aug 28, 2026
13 checks passed
@thaJeztah
thaJeztah deleted the go_modernize branch August 28, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants