grpc-js: Add attributes argument passed from resolver to load balancer

This commit is contained in:
Michael Lumish 2020-04-24 11:34:26 -07:00
parent b4af434b37
commit 08dd114951
5 changed files with 21 additions and 11 deletions

View File

@ -67,7 +67,8 @@ export interface LoadBalancer {
*/
updateAddressList(
addressList: SubchannelAddress[],
lbConfig: LoadBalancingConfig | null
lbConfig: LoadBalancingConfig | null,
attributes: {[key: string]: unknown}
): void;
/**
* If the load balancer is currently in the IDLE state, start connecting.

View File

@ -124,7 +124,7 @@ class DnsResolver implements Resolver {
if (this.ipResult !== null) {
trace('Returning IP address for target ' + uriToString(this.target));
setImmediate(() => {
this.listener.onSuccessfulResolution(this.ipResult!, null, null);
this.listener.onSuccessfulResolution(this.ipResult!, null, null, {});
});
return;
}
@ -186,7 +186,8 @@ class DnsResolver implements Resolver {
this.listener.onSuccessfulResolution(
this.latestLookupResult,
this.latestServiceConfig,
this.latestServiceConfigError
this.latestServiceConfigError,
{}
);
},
(err) => {
@ -230,7 +231,8 @@ class DnsResolver implements Resolver {
this.listener.onSuccessfulResolution(
this.latestLookupResult,
this.latestServiceConfig,
this.latestServiceConfigError
this.latestServiceConfigError,
{}
);
}
},
@ -244,7 +246,8 @@ class DnsResolver implements Resolver {
this.listener.onSuccessfulResolution(
this.latestLookupResult,
this.latestServiceConfig,
this.latestServiceConfigError
this.latestServiceConfigError,
{}
);
}
}

View File

@ -38,7 +38,8 @@ class UdsResolver implements Resolver {
this.listener.onSuccessfulResolution,
this.addresses,
null,
null
null,
{}
);
}

View File

@ -39,7 +39,8 @@ export interface ResolverListener {
onSuccessfulResolution(
addressList: SubchannelAddress[],
serviceConfig: ServiceConfig | null,
serviceConfigError: StatusObject | null
serviceConfigError: StatusObject | null,
attributes: {[key: string]: unknown}
): void;
/**
* Called whenever a name resolution attempt fails.

View File

@ -136,7 +136,8 @@ export class ResolvingLoadBalancer implements LoadBalancer {
onSuccessfulResolution: (
addressList: SubchannelAddress[],
serviceConfig: ServiceConfig | null,
serviceConfigError: ServiceError | null
serviceConfigError: ServiceError | null,
attributes: {[key: string]: unknown}
) => {
let workingServiceConfig: ServiceConfig | null = null;
/* This first group of conditionals implements the algorithm described
@ -211,12 +212,14 @@ export class ResolvingLoadBalancer implements LoadBalancer {
)!;
this.innerLoadBalancer.updateAddressList(
addressList,
loadBalancingConfig
loadBalancingConfig,
attributes
);
} else if (this.innerLoadBalancer.getTypeName() === loadBalancerName) {
this.innerLoadBalancer.updateAddressList(
addressList,
loadBalancingConfig
loadBalancingConfig,
attributes
);
} else {
if (
@ -234,7 +237,8 @@ export class ResolvingLoadBalancer implements LoadBalancer {
}
this.pendingReplacementLoadBalancer.updateAddressList(
addressList,
loadBalancingConfig
loadBalancingConfig,
attributes
);
}
},