Skip to content

Commit

Permalink
chore(grpc): set metadata if not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Nov 12, 2024
1 parent 863b31e commit 4354f91
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/grpc/src/comsumer/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,39 @@ export class GRPCClients extends Map {
let genericFunctionName;
switch (genericFunctionSelector) {
case 0:
options.metadata.set('rpc.method.type', 'unary');
if (! options.metadata.get('rpc.method.type')) {

Check failure on line 118 in packages/grpc/src/comsumer/clients.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`

Check failure on line 118 in packages/grpc/src/comsumer/clients.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`
options.metadata.set('rpc.method.type', 'unary');
}
genericFunctionName = new ClientUnaryRequest(
client,
originalFunction,
options
);
break;
case 1:
options.metadata.set('rpc.method.type', 'server'); // server streaming
if (! options.metadata.get('rpc.method.type')) {

Check failure on line 128 in packages/grpc/src/comsumer/clients.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`

Check failure on line 128 in packages/grpc/src/comsumer/clients.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`
options.metadata.set('rpc.method.type', 'server'); // server streaming
}
genericFunctionName = new ClientReadableRequest(
client,
originalFunction,
options
);
break;
case 2:
options.metadata.set('rpc.method.type', 'client'); // client streaming
if (! options.metadata.get('rpc.method.type')) {

Check failure on line 138 in packages/grpc/src/comsumer/clients.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`

Check failure on line 138 in packages/grpc/src/comsumer/clients.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`
options.metadata.set('rpc.method.type', 'client'); // client streaming
}
genericFunctionName = new ClientWritableRequest(
client,
originalFunction,
options
);
break;
case 3:
options.metadata.set('rpc.method.type', 'bidi'); // bidirectional streaming
if (! options.metadata.get('rpc.method.type')) {

Check failure on line 148 in packages/grpc/src/comsumer/clients.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`

Check failure on line 148 in packages/grpc/src/comsumer/clients.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`
options.metadata.set('rpc.method.type', 'bidi'); // bidirectional streaming
}
genericFunctionName = new ClientDuplexStreamRequest(
client,
originalFunction,
Expand Down

0 comments on commit 4354f91

Please sign in to comment.