From 0b42d034e8e06fcdf782e9392d4fdef09d149741 Mon Sep 17 00:00:00 2001 From: chenwei67 Date: Thu, 3 Nov 2022 23:12:07 +0800 Subject: [PATCH] feat:cli support custom grpc metadata --- client/dtmgrpc/dtmgimp/utils.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/dtmgrpc/dtmgimp/utils.go b/client/dtmgrpc/dtmgimp/utils.go index ac8f0a1..2bb6ba5 100644 --- a/client/dtmgrpc/dtmgimp/utils.go +++ b/client/dtmgrpc/dtmgimp/utils.go @@ -61,18 +61,18 @@ const dtmpre string = "dtm-" // TransInfo2Ctx add trans info to grpc context func TransInfo2Ctx(ctx context.Context, gid, transType, branchID, op, dtm string) context.Context { - md := metadata.Pairs( + nctx := ctx + if ctx == nil { + nctx = context.Background() + } + return metadata.AppendToOutgoingContext( + nctx, dtmpre+"gid", gid, dtmpre+"trans_type", transType, dtmpre+"branch_id", branchID, dtmpre+"op", op, dtmpre+"dtm", dtm, ) - nctx := ctx - if ctx == nil { - nctx = context.Background() - } - return metadata.NewOutgoingContext(nctx, md) } // Map2Kvs map to metadata kv