[go-nuts] Re: storing transaction in context

2017-02-08 Thread Manlio Perillo
Il giorno martedì 7 febbraio 2017 03:57:25 UTC+1, Steve Roth ha scritto: > > I'd like input on whether the following idea is good or bad, and why. > > Consider an abstract transaction, modeled as follows: > func Transaction(ctx context.Context, body func(ctx context.Context) > error) error > Is T

[go-nuts] Re: storing transaction in context

2017-02-07 Thread Steve Roth
Fascinating. I didn't entertain the idea of putting the context in the transaction, for exactly the reason that Chetan cited. But it does seem like a good answer. (And yes, the transactions are short. Long-running transactions are an anti-pattern in their own right.) Many thanks for the inp

[go-nuts] Re: storing transaction in context

2017-02-07 Thread Dave Cheney
I guess it depends on how long your transaction lasts for; it doesn't sound like it lives for that long. IMO the advice about storing contexts in other objects is more about "don't put this into a long lived object", like your server's main loop or something. On Wednesday, 8 February 2017 05:12