-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a mock clock #17
Comments
So, I created this library because metrics kept showing up in performance profiles.
The best we could do would be to have a global clock and mock it via an environment variable (on init). |
Not sure how you'd inject a clock via an environment variable, the caller needs to be able to control the (mock) clock. We could introduce a The interesting thing here is that once a |
Uh, sorry, not environment variable. Global variable.
That also works, but it would likely still be a global. |
Thanks for the input. I'm going then (unless someone says otherwise) with the global |
@marten-seemann @Stebalien We're sharing the global sweeper across tests so the above isn't correct and I'll need some advice on how to proceed. |
Context: libp2p/go-libp2p-core#267
It seems all
Meter
s use a singleglobalSweeper
running on the Go clock. I'm not sure how to go about this. For example:Meter
have its ownsweeper
now (with its own mock/Go clock)?globalSweeper
but somehow have it track individual clocks (either in another structure likemeters []*Meter
or inside theMeter
s themselves)?@Stebalien help (cc @marten-seemann)
The text was updated successfully, but these errors were encountered: