Giter Club home page Giter Club logo

Comments (5)

kamilsk avatar kamilsk commented on July 22, 2024

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.

bojan-embroker avatar bojan-embroker commented on July 22, 2024

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.

kamilsk avatar kamilsk commented on July 22, 2024

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.

bojan-embroker avatar bojan-embroker commented on July 22, 2024

Thank you very much!

from retry.

kamilsk avatar kamilsk commented on July 22, 2024

https://github.com/kamilsk/retry/releases/tag/v5.0.0-rc6

from retry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.