Skip to content

[0 BOUNTY] [Go] Make analytics collector Start idempotent - #142

Open
Saiaaax wants to merge 1 commit into
jaxassistant55:mainfrom
Saiaaax:bounty9-v3
Open

[0 BOUNTY] [Go] Make analytics collector Start idempotent#142
Saiaaax wants to merge 1 commit into
jaxassistant55:mainfrom
Saiaaax:bounty9-v3

Conversation

@Saiaaax

@Saiaaax Saiaaax commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Makes the analytics collector Start() method idempotent — calling it more than once returns ErrAlreadyStarted instead of spawning duplicate flush goroutines.

Closes #9

Changes

  • Modified: market/analytics/collector.go

    • Start(ctx) now returns error — nil on first call, ErrAlreadyStarted on repeat
    • Added started atomic.Bool field to Collector struct
    • Added IsStarted() method reporting flush loop state
    • started flag resets on Stop() and context cancellation
    • Removed TODO comment about making Start idempotent
  • Added: market/analytics/collector_idempotent_test.go — 7 tests:

    • TestCollector_SingleStart
    • TestCollector_RepeatedStart
    • TestCollector_StopAfterRepeatedStart
    • TestCollector_StartAfterStop
    • TestCollector_StartContextCancel
    • TestCollector_ConcurrentStart
    • TestCollector_IsStartedBeforeStart
  • Updated: docs/OPERATIONS.md — Added "Analytics Collector Idempotent Start" section

Testing

go test ./market/analytics/ -run TestCollector -v

Build diagnostic:

python3 build.py -m market

Checklist

  • Relevant modules affected by these changes build locally
  • Tests pass locally
  • Documentation has been updated
  • Changes are scoped to the PR purpose
  • Security, privacy, and error-handling implications have been considered

Payout address: 0x5253757322092903C2F0a8EfEed592344216CC7E

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.

[$50 BOUNTY] [Go] Make analytics collector Start idempotent

1 participant