Browse Source

feat:cli support custom grpc metadata

pull/364/head
chenwei67 3 years ago
parent
commit
0b42d034e8
  1. 12
      client/dtmgrpc/dtmgimp/utils.go

12
client/dtmgrpc/dtmgimp/utils.go

@ -61,18 +61,18 @@ const dtmpre string = "dtm-"
// TransInfo2Ctx add trans info to grpc context // TransInfo2Ctx add trans info to grpc context
func TransInfo2Ctx(ctx context.Context, gid, transType, branchID, op, dtm string) context.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+"gid", gid,
dtmpre+"trans_type", transType, dtmpre+"trans_type", transType,
dtmpre+"branch_id", branchID, dtmpre+"branch_id", branchID,
dtmpre+"op", op, dtmpre+"op", op,
dtmpre+"dtm", dtm, dtmpre+"dtm", dtm,
) )
nctx := ctx
if ctx == nil {
nctx = context.Background()
}
return metadata.NewOutgoingContext(nctx, md)
} }
// Map2Kvs map to metadata kv // Map2Kvs map to metadata kv

Loading…
Cancel
Save