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

Function createDummyPolicy

test/unit/load-balancing-tests.js:562–583  ·  view source on GitHub ↗

* @param {Object} options * @returns {LoadBalancingPolicy}

(options)

Source from the content-addressed store, hash-verified

560 * @returns {LoadBalancingPolicy}
561 */
562function createDummyPolicy(options) {
563 const childPolicy = new LoadBalancingPolicy();
564 childPolicy.initCalled = 0;
565 childPolicy.newQueryPlanCalled = 0;
566 childPolicy.init = function (c, hs, cb) {
567 childPolicy.initCalled++;
568 cb();
569 };
570 childPolicy.getDistance = function (h) {
571 if (h.address.lastIndexOf('_remote') > 0) {
572 return types.distance.remote;
573 }
574 return types.distance.local;
575 };
576 childPolicy.newQueryPlan = function (k, o, cb) {
577 childPolicy.newQueryPlanCalled++;
578
579 const hosts = [ new Host('repl2_local', 2, options), new Host('child1', 2, options), new Host('child2', 2, options) ];
580 cb(null, utils.arrayIterator(hosts));
581 };
582 return childPolicy;
583}
584/**
585 * Creates a dummy host map containing the key as key and value
586 * @param {Array} hosts

Callers 1

Calls 1

cbFunction · 0.85

Tested by

no test coverage detected