Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert(/^[A-Za-z0-9][A-Za-z0-9-]*$/.test(options.prefix), 'Invalid prefix');
assert(options.prefix.length <= 6, 'Prefix is too long');
assert(options.resolvedQueue, 'A resolvedQueue name must be given');
assert(options.claimQueue, 'A claimQueue name must be given');
assert(options.deadlineQueue, 'A deadlineQueue name must be given');
assert(options.monitor, 'A monitor instance must be given');
options = _.defaults({}, options, {
pendingPollTimeout: 5 * 60 * 1000,
deadlineDelay: 10 * 60 * 1000,
});
this.prefix = options.prefix;
this.pendingPollTimeout = options.pendingPollTimeout;
this.monitor = options.monitor;
this.client = new azure.Queue({
accountId: options.credentials.accountName,
accessKey: options.credentials.accountKey,
timeout: AZURE_QUEUE_TIMEOUT,
});
// Store account name of use in SAS signed Urls
this.accountName = options.credentials.accountName;
// Promises that queues are created, return mapping from priority to
// azure queue names.
this.queues = {};
// Resets queues cache every 25 hours, this ensures that meta-data is kept
// up-to-date with a last_used field no more than 48 hours behind
setInterval(() => {this.queues = {};}, 25 * 60 * 60 * 1000);
assert(options.prefix.length <= 6, 'Prefix is too long');
assert(options.resolvedQueue, 'A resolvedQueue name must be given');
assert(options.claimQueue, 'A claimQueue name must be given');
assert(options.deadlineQueue, 'A deadlineQueue name must be given');
assert(options.monitor, 'A monitor instance must be given');
options = _.defaults({}, options, {
deadlineDelay: 10 * 60 * 1000,
});
this.prefix = options.prefix;
this.monitor = options.monitor;
if (options.credentials.fake) {
this.client = new FakeQueueClient();
} else {
this.client = new azure.Queue({
accountId: options.credentials.accountId,
accessKey: options.credentials.accessKey,
timeout: AZURE_QUEUE_TIMEOUT,
});
}
// Store account name of use in SAS signed Urls
this.accountId = options.credentials.accountId;
// Promises that queues are created, return mapping from priority to
// azure queue names.
this.queues = {};
// Resets queues cache every 25 hours, this ensures that meta-data is kept
// up-to-date with a last_used field no more than 48 hours behind
this.queueResetInterval = setInterval(() => {this.queues = {};}, 25 * 60 * 60 * 1000);