ReuseStep marks ctx so wrapped model calls under it share one debug step.
(ctx context.Context)
| 69 | |
| 70 | // ReuseStep marks ctx so wrapped model calls under it share one debug step. |
| 71 | func ReuseStep(ctx context.Context) context.Context { |
| 72 | if holder, ok := reuseHolderFromContext(ctx); ok { |
| 73 | return context.WithValue(ctx, reuseStepKey{}, holder) |
| 74 | } |
| 75 | return context.WithValue(ctx, reuseStepKey{}, &reuseHolder{}) |
| 76 | } |
| 77 | |
| 78 | func reuseHolderFromContext(ctx context.Context) (*reuseHolder, bool) { |
| 79 | holder, ok := ctx.Value(reuseStepKey{}).(*reuseHolder) |