mirror of https://github.com/grpc/grpc-node.git
Merge pull request #2814 from becoded/call-credential-generate-metadata-method-name
Provide the method_name for the CallCredentials callback generateMetadata
This commit is contained in:
commit
605f14a0b5
|
@ -18,6 +18,7 @@
|
||||||
import { Metadata } from './metadata';
|
import { Metadata } from './metadata';
|
||||||
|
|
||||||
export interface CallMetadataOptions {
|
export interface CallMetadataOptions {
|
||||||
|
method_name: string;
|
||||||
service_url: string;
|
service_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ export class LoadBalancingCall implements Call, DeadlineInfoProvider {
|
||||||
switch (pickResult.pickResultType) {
|
switch (pickResult.pickResultType) {
|
||||||
case PickResultType.COMPLETE:
|
case PickResultType.COMPLETE:
|
||||||
this.credentials
|
this.credentials
|
||||||
.generateMetadata({ service_url: this.serviceUrl })
|
.generateMetadata({ method_name: this.methodName, service_url: this.serviceUrl })
|
||||||
.then(
|
.then(
|
||||||
credsMetadata => {
|
credsMetadata => {
|
||||||
/* If this call was cancelled (e.g. by the deadline) before
|
/* If this call was cancelled (e.g. by the deadline) before
|
||||||
|
|
|
@ -87,6 +87,7 @@ describe('CallCredentials', () => {
|
||||||
generateFromServiceURL
|
generateFromServiceURL
|
||||||
);
|
);
|
||||||
const metadata: Metadata = await callCredentials.generateMetadata({
|
const metadata: Metadata = await callCredentials.generateMetadata({
|
||||||
|
method_name: 'bar',
|
||||||
service_url: 'foo',
|
service_url: 'foo',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ describe('CallCredentials', () => {
|
||||||
CallCredentials.createFromMetadataGenerator(generateWithError);
|
CallCredentials.createFromMetadataGenerator(generateWithError);
|
||||||
let metadata: Metadata | null = null;
|
let metadata: Metadata | null = null;
|
||||||
try {
|
try {
|
||||||
metadata = await callCredentials.generateMetadata({ service_url: '' });
|
metadata = await callCredentials.generateMetadata({ method_name: '', service_url: '' });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.ok(err instanceof Error);
|
assert.ok(err instanceof Error);
|
||||||
}
|
}
|
||||||
|
@ -139,6 +140,7 @@ describe('CallCredentials', () => {
|
||||||
testCases.map(async testCase => {
|
testCases.map(async testCase => {
|
||||||
const { credentials, expected } = testCase;
|
const { credentials, expected } = testCase;
|
||||||
const metadata: Metadata = await credentials.generateMetadata({
|
const metadata: Metadata = await credentials.generateMetadata({
|
||||||
|
method_name: '',
|
||||||
service_url: '',
|
service_url: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue