WithReceipt returns a context who holds a *atomic.Value. A *Receipt will be set to this value after the query succeeds. Note that this context is safe for concurrent queries, but the value may be reset in another goroutines. So if you want to make use of Receipt in several goroutines, you should ca
(ctx context.Context)
| 39 | // goroutines. So if you want to make use of Receipt in several goroutines, you should call this |
| 40 | // method to get separated child context in each goroutine. |
| 41 | func WithReceipt(ctx context.Context) context.Context { |
| 42 | var value atomic.Value |
| 43 | value.Store((*Receipt)(nil)) |
| 44 | return context.WithValue(ctx, &ctxReceiptKey, &value) |
| 45 | } |
| 46 | |
| 47 | // GetReceipt tries to get *Receipt from context. |
| 48 | func GetReceipt(ctx context.Context) (rec *Receipt, ok bool) { |