MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / getDistance

Method getDistance

lib/execution-profile.js:181–196  ·  view source on GitHub ↗

* Uses the load-balancing policies to get the relative distance to the host and return the closest one. * @param {Host} host

(host)

Source from the content-addressed store, hash-verified

179 * @param {Host} host
180 */
181 getDistance(host) {
182 let distance = types.distance.ignored;
183 // this is performance critical: we can't use any other language features than for-loop :(
184 for (let i = 0; i < this._loadBalancingPolicies.length; i++) {
185 const d = this._loadBalancingPolicies[i].getDistance(host);
186 if (d < distance) {
187 distance = d;
188 if (distance === types.distance.local) {
189 break;
190 }
191 }
192 }
193
194 host.setDistance(distance);
195 return distance;
196 }
197
198 /**
199 * @param {String|ExecutionProfile} name

Callers 7

_borrowAConnectionMethod · 0.45
setPeersInfoMethod · 0.45
client.jsFile · 0.45
getNextHostMethod · 0.45
_getDataCentersMethod · 0.45
getNextConnectionMethod · 0.45

Calls 1

setDistanceMethod · 0.80

Tested by

no test coverage detected