From 980a554aa57c5eedf68173309535a0407fa54933 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 17 Feb 2021 11:19:56 +0200 Subject: [PATCH] make UseTransient context option take a reason argument, for consistency with other options --- network/context.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/network/context.go b/network/context.go index 8c01a5d..0eed3cd 100644 --- a/network/context.go +++ b/network/context.go @@ -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 // that it is acceptable to use a transient connection when opening a new stream. -func WithUseTransient(ctx context.Context) context.Context { - return context.WithValue(ctx, useTransient, true) +func WithUseTransient(ctx context.Context, reason string) context.Context { + return context.WithValue(ctx, useTransient, reason) } // 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) if v != nil { - return true + return true, v.(string) } - return false + return false, "" }