Comments (5)
Hi! Yes, retry.Do
doesn't preserve context values when calling action because it expects strategy.Breaker
, not context.Context
.
It is possible to do that:
- ctx, cancel := context.WithCancel(context.Background())
+ ctx, is := breaker.(context.Context)
+ if !is {
+ ctx = context.Background()
+ }
+ ctx, cancel := context.WithCancel(ctx)
I'm not a fan of the Value part of the context, but could you provide some use cases to make a decision.
from retry.
Hi Kamil,
I am used to storing correlation id in context so it gets prepended to all log entries. For instance when I am building a REST API, I use request id as correlation id and I can then easily inspect all log entries produced by a request even if they are interleaved with other entries. That's how I found out retry.Do
isn't preserving values - correlation id was missing from some log entries. There are other ways to do it of course, but projects I work on do it like that.
Database transaction handle also gets stored in context.
from retry.
Thanks, Bojan! I'm preparing the patch and will add some tests to it.
Today it will be ready, the upcoming release is v5.0.0-rc6.
from retry.
Thank you very much!
from retry.
https://github.com/kamilsk/retry/releases/tag/v5.0.0-rc6
from retry.
Related Issues (20)
- unstable behavior on high load
- provide wrappers for retriable error HOT 2
- rename DoAsync to Go
- describe how to switch from v4 to v5
- goroutine leak in v4 HOT 1
- Wrong examples in the README HOT 5
- strategy for context modification HOT 1
- fix lint issues and coverage report
- review tests
- mark CheckError as experimental feature and add typical mistakes HOT 1
- Less may be more HOT 1
- how to guide
- convert internal types to aliases
- improve work with timer
- go playground examples
- unexpected Limit behavior HOT 1
- wat moment: Schrödinger's bug
- prepare to switch to go.octolab.org/retry
- simplify hugo logic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from retry.