Skip to content

refactor(flusher): use &self instead of &mut self for flush methods#69

Merged
duncanista merged 2 commits intomainfrom
jordan.gonzalez/dogstatsd/refactor-using-mutable
Feb 5, 2026
Merged

refactor(flusher): use &self instead of &mut self for flush methods#69
duncanista merged 2 commits intomainfrom
jordan.gonzalez/dogstatsd/refactor-using-mutable

Conversation

@duncanista
Copy link
Contributor

What does this PR do?

Refactors code to improve how &self is used

Motivation

The Flusher methods (get_dd_api, flush, flush_metrics) previously required &mut self, forcing callers to wrap the flusher in a Mutex.

Since tokio::sync::OnceCell::get_or_init() only requires &self, we can change all methods to use &self, enabling lock-free usage.

The Flusher methods (get_dd_api, flush, flush_metrics) previously
  required &mut self, forcing callers to wrap the flusher in a Mutex.

  Since tokio::sync::OnceCell::get_or_init() only requires &self,
  we can change all methods to use &self, enabling lock-free usage.

  Also fixes test assertions: 404 is a permanent error (4xx) that
  should not be retried, so flush_metrics correctly returns None.
@duncanista duncanista requested review from a team as code owners February 4, 2026 22:37
@duncanista duncanista requested review from kathiehuang and removed request for a team February 4, 2026 22:37
@duncanista duncanista merged commit e4f0341 into main Feb 5, 2026
26 checks passed
@duncanista duncanista deleted the jordan.gonzalez/dogstatsd/refactor-using-mutable branch February 5, 2026 14:44
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.

2 participants