@azure/event-hubs
Version:
Azure Event Hubs SDK for JS.
56 lines (55 loc) • 2.33 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var greedyStrategy_exports = {};
__export(greedyStrategy_exports, {
GreedyLoadBalancingStrategy: () => GreedyLoadBalancingStrategy
});
module.exports = __toCommonJS(greedyStrategy_exports);
var import_loadBalancingStrategy = require("./loadBalancingStrategy.js");
class GreedyLoadBalancingStrategy {
/**
* Creates an instance of GreedyLoadBalancingStrategy.
*
* @param _partitionOwnershipExpirationIntervalInMs - The length of time a partition claim is valid.
*/
constructor(_partitionOwnershipExpirationIntervalInMs) {
this._partitionOwnershipExpirationIntervalInMs = _partitionOwnershipExpirationIntervalInMs;
}
_partitionOwnershipExpirationIntervalInMs;
/**
* Implements load balancing by taking into account current ownership and
* the new set of partitions to add.
* @param ourOwnerId - The id we should assume is _our_ id when checking for ownership.
* @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.
* @param partitionIds - Partitions to assign owners to.
* @returns Partition ids to claim.
*/
getPartitionsToClaim(ourOwnerId, claimedPartitionOwnershipMap, partitionIds) {
return (0, import_loadBalancingStrategy.listAvailablePartitions)(
ourOwnerId,
claimedPartitionOwnershipMap,
partitionIds,
this._partitionOwnershipExpirationIntervalInMs
);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
GreedyLoadBalancingStrategy
});
//# sourceMappingURL=greedyStrategy.js.map