Commit 980a554a authored by vyzo's avatar vyzo

make UseTransient context option take a reason argument, for consistency with other options

parent a21b06e6
...@@ -71,15 +71,15 @@ func WithDialPeerTimeout(ctx context.Context, timeout time.Duration) context.Con ...@@ -71,15 +71,15 @@ func WithDialPeerTimeout(ctx context.Context, timeout time.Duration) context.Con
// WithUseTransient constructs a new context with an option that instructs the network // WithUseTransient constructs a new context with an option that instructs the network
// that it is acceptable to use a transient connection when opening a new stream. // that it is acceptable to use a transient connection when opening a new stream.
func WithUseTransient(ctx context.Context) context.Context { func WithUseTransient(ctx context.Context, reason string) context.Context {
return context.WithValue(ctx, useTransient, true) return context.WithValue(ctx, useTransient, reason)
} }
// GetUseTransient returns true if the use transient option is set in the context. // GetUseTransient returns true if the use transient option is set in the context.
func GetUseTransient(ctx context.Context) bool { func GetUseTransient(ctx context.Context) (usetransient bool, reason string) {
v := ctx.Value(useTransient) v := ctx.Value(useTransient)
if v != nil { if v != nil {
return true return true, v.(string)
} }
return false return false, ""
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment