Comparing version 2.1.22 to 2.1.23
@@ -8,6 +8,6 @@ import { Database } from './src/sqns/common/database'; | ||
import { SQNSClientConfig } from './typings/client-confriguation'; | ||
import { UpdateMessageById } from './typings/publish'; | ||
import { FindMessageByIdResult, UpdateMessageByIdResult } from './typings/recieve-message'; | ||
import { UpdateMessageByDeduplicationId, UpdateMessageById } from './typings/publish'; | ||
import { FindMessageByIdResult, UpdateMessageByDeduplicationIdResult, UpdateMessageByIdResult } from './typings/recieve-message'; | ||
import { ResponseItem } from './typings/response-item'; | ||
import { MessageAttributeMap, SendMessageRequest, SendMessage } from './typings/typings'; | ||
export { EventState, UpdateMessageById, UpdateMessageByIdResult, ManagerEventScheduler, WorkerEventScheduler, FindMessageByIdResult, SendMessage, SQNSClient, SQNS, SQNSClientConfig, Database, ResponseItem, SendMessageRequest, MessageAttributeMap, }; | ||
import { MessageAttributeMap, SendMessage, SendMessageRequest } from './typings/typings'; | ||
export { EventState, UpdateMessageByDeduplicationId, UpdateMessageByDeduplicationIdResult, UpdateMessageById, UpdateMessageByIdResult, ManagerEventScheduler, WorkerEventScheduler, FindMessageByIdResult, SendMessage, SQNSClient, SQNS, SQNSClientConfig, Database, ResponseItem, SendMessageRequest, MessageAttributeMap, }; |
{ | ||
"name": "sqns", | ||
"version": "2.1.22", | ||
"version": "2.1.23", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,3 +25,3 @@ import { TopicAttributes, TopicTag } from '../../../../../typings/class-types'; | ||
addEventItem(queue: Queue, eventItem: EventItem): Promise<EventItem>; | ||
findEventsToProcess(queues: Array<Queue>, time: Date, limit: number): Promise<Array<EventItem>>; | ||
findEventsToProcess(time: Date, limit: number): Promise<Array<EventItem>>; | ||
getQueues(queueARNPrefix: string): Promise<Array<Queue>>; | ||
@@ -28,0 +28,0 @@ updateEvent(id: string, data: { |
@@ -66,8 +66,7 @@ "use strict"; | ||
} | ||
async findEventsToProcess(queues, time, limit) { | ||
async findEventsToProcess(time, limit) { | ||
const query = { | ||
queueARN: { $in: queues.map((queue) => queue.arn) }, | ||
maxAttemptCompleted: false, | ||
eventTime: { $lt: time }, | ||
state: { $in: [event_item_1.EventItem.State.PENDING, event_item_1.EventItem.State.PROCESSING, event_item_1.EventItem.State.FAILURE] }, | ||
$expr: { $lt: ['$receiveCount', '$maxReceiveCount'] }, | ||
}; | ||
@@ -74,0 +73,0 @@ log.info('DB Fetch ', query); |
@@ -107,2 +107,3 @@ "use strict"; | ||
processingResponse: 'sent to slave', | ||
maxAttemptCompleted: false, | ||
failureResponse: 'Event marked failed without response.', | ||
@@ -119,2 +120,3 @@ DeliveryPolicy: null, | ||
MessageAttribute: {}, | ||
maxAttemptCompleted: false, | ||
state: 'PROCESSING', | ||
@@ -132,2 +134,3 @@ processingResponse: 'sent to slave', | ||
MessageAttribute: {}, | ||
maxAttemptCompleted: false, | ||
state: 'SUCCESS', | ||
@@ -250,2 +253,3 @@ processingResponse: 'sent to slave', | ||
queueARN: 'arn:sqns:sqs:sqns:1:queue1', | ||
maxAttemptCompleted: false, | ||
failureResponse: 'Event marked failed without response.', | ||
@@ -252,0 +256,0 @@ processingResponse: 'sent to slave', |
@@ -29,3 +29,3 @@ import { TopicAttributes, TopicTag } from '../../../../typings/class-types'; | ||
findById(id: string): Promise<EventItem>; | ||
findEventsToProcess(queues: Array<Queue>, time: Date, limit: number): Promise<Array<EventItem>>; | ||
findEventsToProcess(time: Date, limit: number): Promise<Array<EventItem>>; | ||
updateEvent(id: string, data: { | ||
@@ -32,0 +32,0 @@ [key: string]: any; |
@@ -23,2 +23,3 @@ import { EventItemType } from '../../../../typings/class-types'; | ||
priority: number; | ||
maxAttemptCompleted: boolean; | ||
receiveCount: number; | ||
@@ -37,2 +38,3 @@ maxReceiveCount: number; | ||
setDelaySeconds(DelaySeconds: number): void; | ||
setReceiveCount(receiveCount: number): void; | ||
} |
@@ -16,3 +16,3 @@ "use strict"; | ||
this.priority = Number.MAX_SAFE_INTEGER; | ||
this.receiveCount = item.receiveCount || 0; | ||
this.setReceiveCount(item.receiveCount || 0); | ||
this.queueARN = item.queueARN; | ||
@@ -47,3 +47,3 @@ this.maxReceiveCount = item.maxReceiveCount; | ||
incrementReceiveCount() { | ||
this.receiveCount += 1; | ||
this.setReceiveCount(this.receiveCount + 1); | ||
} | ||
@@ -77,2 +77,9 @@ setState(state) { | ||
} | ||
setReceiveCount(receiveCount) { | ||
if (receiveCount === undefined) { | ||
return; | ||
} | ||
this.receiveCount = Math.max(0, receiveCount); | ||
this.maxAttemptCompleted = this.receiveCount >= this.maxReceiveCount; | ||
} | ||
} | ||
@@ -79,0 +86,0 @@ exports.EventItem = EventItem; |
@@ -20,5 +20,5 @@ import { QueueType } from '../../../../typings/class-types'; | ||
constructor(item: QueueType); | ||
getMaxReceiveCount(): number; | ||
getMaxReceiveCount(maxReceiveCount: string): number; | ||
private getARN; | ||
} | ||
export { Queue }; |
@@ -25,3 +25,6 @@ "use strict"; | ||
} | ||
getMaxReceiveCount() { | ||
getMaxReceiveCount(maxReceiveCount) { | ||
if (maxReceiveCount && !isNaN(Number(maxReceiveCount))) { | ||
return Math.max(Number(maxReceiveCount), 1); | ||
} | ||
return Math.max(Number(this.attributes.maxReceiveCount || '3'), 1); | ||
@@ -28,0 +31,0 @@ } |
@@ -136,4 +136,3 @@ "use strict"; | ||
async sendMessage(queue, MessageBody, MessageAttribute, MessageSystemAttribute, DelaySeconds = '0', MessageDeduplicationId) { | ||
var _a, _b, _c; | ||
this.storageToQueueWorker.setUpIntervalForQueue(queue); | ||
var _a, _b, _c, _d; | ||
const deliveryPolicy = delivery_policy_helper_1.DeliveryPolicyHelper | ||
@@ -152,3 +151,3 @@ .verifyAndGetChannelDeliveryPolicy((_a = MessageAttribute === null || MessageAttribute === void 0 ? void 0 : MessageAttribute.DeliveryPolicy) === null || _a === void 0 ? void 0 : _a.StringValue); | ||
MessageDeduplicationId, | ||
maxReceiveCount: queue.getMaxReceiveCount(), | ||
maxReceiveCount: queue.getMaxReceiveCount((_d = MessageAttribute === null || MessageAttribute === void 0 ? void 0 : MessageAttribute.MaxReceiveCount) === null || _d === void 0 ? void 0 : _d.StringValue), | ||
priority, | ||
@@ -155,0 +154,0 @@ eventTime: new Date(new Date().getTime() + (Number(DelaySeconds) * 1000)), |
@@ -8,3 +8,3 @@ import { ARN, KeyValueString } from '../../../../typings/common'; | ||
addEventItem(queue: Queue, eventItem: EventItem): Promise<EventItem>; | ||
findEventsToProcess(queues: Array<Queue>, time: Date, limit: number): Promise<Array<EventItem>>; | ||
findEventsToProcess(time: Date, limit: number): Promise<Array<EventItem>>; | ||
updateEventStateProcessing(queue: Queue, eventItem_: EventItem, visibilityTimeout: number, message: string): Promise<any>; | ||
@@ -11,0 +11,0 @@ updateEvent(queue: Queue, eventItem: EventItem): Promise<any>; |
@@ -12,4 +12,4 @@ "use strict"; | ||
} | ||
findEventsToProcess(queues, time, limit) { | ||
return this._storageAdapter.findEventsToProcess(queues, time, limit); | ||
findEventsToProcess(time, limit) { | ||
return this._storageAdapter.findEventsToProcess(time, limit); | ||
} | ||
@@ -16,0 +16,0 @@ async updateEventStateProcessing(queue, eventItem_, visibilityTimeout, message) { |
@@ -106,5 +106,6 @@ "use strict"; | ||
case 'UpdateMessageByDeduplicationId': { | ||
const { MessageDeduplicationId, queueName, DelaySeconds, State, region, requestId, } = req.serverBody; | ||
const { MessageDeduplicationId, queueName, DelaySeconds, State, region, ReceiveCount, requestId, } = req.serverBody; | ||
const queue = await this.eventManager.getQueue(queue_1.Queue.arn(req.user.organizationId, region, queueName)); | ||
const eventItem = await this.eventManager.findMessageByDeduplicationId(queue, MessageDeduplicationId); | ||
eventItem.setReceiveCount(ReceiveCount); | ||
eventItem.setState(State); | ||
@@ -111,0 +112,0 @@ eventItem.setDelaySeconds(DelaySeconds); |
import { BASE_CONFIG, KeyValue } from '../../../../typings/common'; | ||
import { QueueStorageToQueueConfigListener } from '../../../../typings/config'; | ||
import { Queue } from '../../common/model/queue'; | ||
export declare class QueueStorageToQueueConfig { | ||
@@ -8,4 +7,2 @@ private _sending; | ||
private _listener; | ||
private _queues; | ||
private _knownQueueARN; | ||
get sending(): boolean; | ||
@@ -17,6 +14,3 @@ set sending(value: boolean); | ||
set listener(value: QueueStorageToQueueConfigListener); | ||
get queues(): Array<Queue>; | ||
set queues(value: Array<Queue>); | ||
get knownQueueARN(): KeyValue<boolean>; | ||
get cloneBaseParams(): KeyValue; | ||
} |
@@ -7,4 +7,2 @@ "use strict"; | ||
this._sending = false; | ||
this._queues = []; | ||
this._knownQueueARN = {}; | ||
} | ||
@@ -29,11 +27,2 @@ get sending() { | ||
} | ||
get queues() { | ||
return this._queues; | ||
} | ||
set queues(value) { | ||
this._queues = value; | ||
} | ||
get knownQueueARN() { | ||
return this._knownQueueARN; | ||
} | ||
get cloneBaseParams() { | ||
@@ -40,0 +29,0 @@ if (typeof this.baseParams === 'function') { |
import { BASE_CONFIG } from '../../../../typings/common'; | ||
import { QueueStorageToQueueConfigListener } from '../../../../typings/config'; | ||
import { Queue } from '../../common/model/queue'; | ||
export declare class QueueStorageToQueueScheduler { | ||
private _job; | ||
private config; | ||
constructor(queue: Queue, baseParams: BASE_CONFIG, listener: QueueStorageToQueueConfigListener, cronInterval?: string); | ||
constructor(baseParams: BASE_CONFIG, listener: QueueStorageToQueueConfigListener, cronInterval?: string); | ||
cancel(): void; | ||
addQueue(queue: Queue): void; | ||
private getQueueNames; | ||
private startProcessingOfQueue; | ||
@@ -12,0 +9,0 @@ private findEventsToAddInQueueAsynchronous; |
@@ -28,8 +28,7 @@ "use strict"; | ||
class QueueStorageToQueueScheduler { | ||
constructor(queue, baseParams, listener, cronInterval) { | ||
constructor(baseParams, listener, cronInterval) { | ||
this.config = new queue_storage_to_queue_config_1.QueueStorageToQueueConfig(); | ||
this.config.listener = listener; | ||
this.addQueue(queue); | ||
this.config.baseParams = baseParams; | ||
log.info(`Adding scheduler job for queueARN: ${queue.arn}`); | ||
log.info('Adding scheduler job'); | ||
this._job = schedule.scheduleJob(cronInterval || '*/5 * * * * *', () => { | ||
@@ -43,24 +42,13 @@ log.info('Executing Manage Job Interval'); | ||
} | ||
addQueue(queue) { | ||
if (this.config.knownQueueARN[queue.arn]) { | ||
return; | ||
} | ||
log.info(`Adding queueARN: ${queue.arn}`); | ||
this.config.knownQueueARN[queue.arn] = true; | ||
this.config.queues.push(queue); | ||
} | ||
getQueueNames() { | ||
return this.config.queues.map((each) => each.name); | ||
} | ||
startProcessingOfQueue() { | ||
if (this.config.sending) { | ||
log.verbose('Queues:', this.getQueueNames(), 'already fetching events.'); | ||
log.verbose('already fetching events.'); | ||
return; | ||
} | ||
log.info('Queues:', this.getQueueNames(), 'start fetching events.'); | ||
this.findEventsToAddInQueueAsynchronous(this.config.queues.map((each) => each), this.config.cloneBaseParams); | ||
log.info('start fetching events.'); | ||
this.findEventsToAddInQueueAsynchronous(this.config.cloneBaseParams); | ||
} | ||
findEventsToAddInQueueAsynchronous(queues, itemListParams) { | ||
findEventsToAddInQueueAsynchronous(itemListParams) { | ||
this.config.sending = true; | ||
this.findEventsToAddInQueue(queues, itemListParams) | ||
this.findEventsToAddInQueue(itemListParams) | ||
.catch((error) => { | ||
@@ -71,10 +59,10 @@ log.error(error); | ||
} | ||
async findEventsToAddInQueue(queues, itemListParams) { | ||
const [nextItemListParams, hasMoreData] = await this.config.listener(queues, itemListParams); | ||
async findEventsToAddInQueue(itemListParams) { | ||
const [nextItemListParams, hasMoreData] = await this.config.listener(itemListParams); | ||
if (!hasMoreData) { | ||
log.info('Queues:', this.getQueueNames(), 'No more data to fetch, resetting.'); | ||
log.info('No more data to fetch, resetting.'); | ||
this.config.sending = false; | ||
return; | ||
} | ||
this.findEventsToAddInQueueAsynchronous(queues, nextItemListParams); | ||
this.findEventsToAddInQueueAsynchronous(nextItemListParams); | ||
} | ||
@@ -81,0 +69,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const setup_1 = require("../../../setup"); | ||
const queue_1 = require("../../common/model/queue"); | ||
const queue_storage_to_queue_scheduler_1 = require("./queue-storage-to-queue-scheduler"); | ||
@@ -14,3 +13,3 @@ describe('QueueStorageToQueueSchedulerSpec', () => { | ||
const timeout = setTimeout(() => reject('should not reach here.'), 6000); | ||
queueStorageToQueueScheduler = new queue_storage_to_queue_scheduler_1.QueueStorageToQueueScheduler(new queue_1.Queue({ name: 'queue1' }), () => ({}), async () => { | ||
queueStorageToQueueScheduler = new queue_storage_to_queue_scheduler_1.QueueStorageToQueueScheduler(() => ({}), async () => { | ||
if (!attempt) { | ||
@@ -17,0 +16,0 @@ clearTimeout(timeout); |
import { EventItem } from '../../common/model/event-item'; | ||
import { Queue } from '../../common/model/queue'; | ||
import { SQSStorageEngine } from '../manager/s-q-s-storage-engine'; | ||
@@ -11,5 +10,4 @@ declare class StorageToQueueWorker { | ||
constructor(storageEngine: SQSStorageEngine, addEventToQueueListener: (eventItem: EventItem) => void, cronInterval: string); | ||
setUpIntervalForQueue(queue: Queue): void; | ||
setUpIntervalForQueue(): void; | ||
cancel(): void; | ||
private setUpInterval; | ||
private baseParams; | ||
@@ -16,0 +14,0 @@ private setUpListener; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StorageToQueueWorker = void 0; | ||
const logger_1 = require("../../common/logger/logger"); | ||
const queue_storage_to_queue_scheduler_1 = require("./queue-storage-to-queue-scheduler"); | ||
const log = logger_1.logger.instance('StorageToQueueWorker'); | ||
class StorageToQueueWorker { | ||
@@ -13,13 +11,6 @@ constructor(storageEngine, addEventToQueueListener, cronInterval) { | ||
this.setUpListener(); | ||
this.setUpInterval().catch((error) => { | ||
log.error(error); | ||
}); | ||
this.setUpIntervalForQueue(); | ||
} | ||
setUpIntervalForQueue(queue) { | ||
if (!this._queueStorageToQueueScheduler) { | ||
this._queueStorageToQueueScheduler = new queue_storage_to_queue_scheduler_1.QueueStorageToQueueScheduler(queue, this.baseParams(), this._listener, this.cronInterval); | ||
} | ||
else { | ||
this._queueStorageToQueueScheduler.addQueue(queue); | ||
} | ||
setUpIntervalForQueue() { | ||
this._queueStorageToQueueScheduler = new queue_storage_to_queue_scheduler_1.QueueStorageToQueueScheduler(this.baseParams(), this._listener, this.cronInterval); | ||
} | ||
@@ -30,6 +21,2 @@ cancel() { | ||
} | ||
async setUpInterval() { | ||
const queues = await this._storageEngine.listQueues(undefined); | ||
queues.forEach((queue) => this.setUpIntervalForQueue(queue)); | ||
} | ||
baseParams() { | ||
@@ -39,4 +26,4 @@ return () => ({ time: new Date() }); | ||
setUpListener() { | ||
this._listener = async (queues, { time }) => { | ||
const items = await this._storageEngine.findEventsToProcess(queues, time, 100); | ||
this._listener = async ({ time }) => { | ||
const items = await this._storageEngine.findEventsToProcess(time, 100); | ||
if (!items.length) { | ||
@@ -43,0 +30,0 @@ return [{}, false]; |
@@ -30,2 +30,3 @@ import { EventState } from '../src/sqns/common/model/event-item'; | ||
priority: number; | ||
maxAttemptCompleted?: boolean; | ||
sentTime?: Date; | ||
@@ -32,0 +33,0 @@ firstSentTime?: Date; |
import { Database } from '../src/sqns/common/database'; | ||
import { Queue } from '../src/sqns/common/model/queue'; | ||
import { KeyValue } from './common'; | ||
@@ -61,2 +60,2 @@ import { RequestItem } from './request-item'; | ||
} | ||
export declare type QueueStorageToQueueConfigListener = (queues: Array<Queue>, nextItemListParams: KeyValue) => Promise<[KeyValue, boolean]>; | ||
export declare type QueueStorageToQueueConfigListener = (nextItemListParams: KeyValue) => Promise<[KeyValue, boolean]>; |
@@ -36,2 +36,3 @@ import { EventState } from '../src/sqns/common/model/event-item'; | ||
DelaySeconds?: number; | ||
ReceiveCount?: number; | ||
State?: EventState; | ||
@@ -38,0 +39,0 @@ } |
@@ -1,2 +0,1 @@ | ||
import { SendMessage } from './send-message'; | ||
import { ClientConfiguration } from './client-confriguation'; | ||
@@ -9,5 +8,5 @@ import { ARN, BASE_CONFIG, KeyValue, MessageAttributeEntry, MessageAttributeMap, MessageAttributes, SupportedProtocol, SUPPORTED_BACKOFF_FUNCTIONS_TYPE, SUPPORTED_CHANNEL_TYPE } from './common'; | ||
import { RequestItem } from './request-item'; | ||
import { SendMessageBatchRequest, SendMessageBatchResult, SendMessageRequest, SendMessageResult } from './send-message'; | ||
import { SendMessage, SendMessageBatchRequest, SendMessageBatchResult, SendMessageRequest, SendMessageResult } from './send-message'; | ||
import { ConfirmSubscriptionInput, ConfirmSubscriptionResponse, ListSubscriptionsByTopicInput, ListSubscriptionsByTopicResponse, ListSubscriptionsInput, ListSubscriptionsResponse, SubscribeInput, SubscriptionConfirmationRequestBody, UnsubscribeInput } from './subscription'; | ||
import { CreateTopicInput, CreateTopicResponse, DeleteTopicInput, GetTopicAttributesInput, GetTopicAttributesResponse, ListTopicsInput, ListTopicsResponse, SetTopicAttributesInput } from './topic'; | ||
export { ClientConfiguration, SendMessageRequest, SendMessageResult, SendMessageBatchRequest, ReceiveMessageRequest, ReceiveMessageResult, SendMessageBatchResult, ListQueuesResponse, ListQueuesRequest, CreateQueueRequest, CreateQueueResult, GetQueueUrlRequest, GetQueueUrlResult, DeleteQueueRequest, SubscribeInput, PublishInput, PublishResponse, CreateTopicInput, CreateTopicResponse, ConfirmSubscriptionInput, ConfirmSubscriptionResponse, ListSubscriptionsByTopicInput, ListSubscriptionsByTopicResponse, ListSubscriptionsInput, ListSubscriptionsResponse, UnsubscribeInput, ListTopicsInput, ListTopicsResponse, GetTopicAttributesInput, GetTopicAttributesResponse, DeleteTopicInput, SetTopicAttributesInput, MessageStructure, SubscriptionConfirmationRequestBody, SUPPORTED_CHANNEL_TYPE, SUPPORTED_BACKOFF_FUNCTIONS_TYPE, MessageAttributes, RequestItem, BASE_CONFIG, KeyValue, ARN, MessageAttributeEntry, MessageAttributeMap, SupportedProtocol, SendMessage, }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
698403
8522