Browse Source
Merge pull request #364 from chenwei67/feature-cli-grpcmd
feat:cli support custom grpc metadata
pull/369/head
yedf2
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
6 deletions
-
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
|
|
|
|
|