Skip to content

Commit

Permalink
Provide the method_name for the CallCredentials callback generateMeta…
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
becoded committed Aug 29, 2024
1 parent 7e4c8f0 commit 268d7eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/grpc-js/src/call-credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { Metadata } from './metadata';

export interface CallMetadataOptions {
method_name: string;
service_url: string;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js/src/load-balancing-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class LoadBalancingCall implements Call, DeadlineInfoProvider {
switch (pickResult.pickResultType) {
case PickResultType.COMPLETE:
this.credentials
.generateMetadata({ service_url: this.serviceUrl })
.generateMetadata({ method_name: this.methodName, service_url: this.serviceUrl })
.then(
credsMetadata => {
/* If this call was cancelled (e.g. by the deadline) before
Expand Down
4 changes: 3 additions & 1 deletion packages/grpc-js/test/test-call-credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('CallCredentials', () => {
generateFromServiceURL
);
const metadata: Metadata = await callCredentials.generateMetadata({
method_name: 'bar',
service_url: 'foo',
});

Expand All @@ -98,7 +99,7 @@ describe('CallCredentials', () => {
CallCredentials.createFromMetadataGenerator(generateWithError);
let metadata: Metadata | null = null;
try {
metadata = await callCredentials.generateMetadata({ service_url: '' });
metadata = await callCredentials.generateMetadata({ method_name: '', service_url: '' });
} catch (err) {
assert.ok(err instanceof Error);
}
Expand Down Expand Up @@ -139,6 +140,7 @@ describe('CallCredentials', () => {
testCases.map(async testCase => {
const { credentials, expected } = testCase;
const metadata: Metadata = await credentials.generateMetadata({
method_name: '',
service_url: '',
});

Expand Down

0 comments on commit 268d7eb

Please sign in to comment.