-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add ProducibleMessage/ConsumableMessage/MessageEnvelope
- Loading branch information
Showing
24 changed files
with
683 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright (c) | ||
* Weyoss <weyoss@protonmail.com> | ||
* https://github.com/weyoss | ||
* | ||
* This source code is licensed under the MIT license found in the LICENSE file | ||
* in the root directory of this source tree. | ||
*/ | ||
|
||
import { MessageEnvelope } from './message-envelope'; | ||
import { | ||
EMessagePriority, | ||
EMessagePropertyStatus, | ||
IMessageSerialized, | ||
IConsumableMessage, | ||
IQueueParams, | ||
TExchange, | ||
TTopicParams, | ||
} from '../../../types'; | ||
|
||
export function _createRMessage(msg: MessageEnvelope): IConsumableMessage { | ||
return { | ||
getPublishedAt(): number | null { | ||
return msg.getPublishedAt(); | ||
}, | ||
|
||
getScheduledAt(): number | null { | ||
return msg.getScheduledAt(); | ||
}, | ||
|
||
getScheduledMessageId(): string | null { | ||
return msg.getScheduledMessageId(); | ||
}, | ||
|
||
getId(): string { | ||
return msg.getId(); | ||
}, | ||
|
||
getStatus(): EMessagePropertyStatus { | ||
return msg.getStatus(); | ||
}, | ||
|
||
hasPriority(): boolean { | ||
return msg.producibleMessage.hasPriority(); | ||
}, | ||
|
||
getQueue(): IQueueParams | string | null { | ||
return msg.producibleMessage.getQueue(); | ||
}, | ||
|
||
getDestinationQueue(): IQueueParams { | ||
return msg.getDestinationQueue(); | ||
}, | ||
|
||
getPriority(): EMessagePriority | null { | ||
return msg.producibleMessage.getPriority(); | ||
}, | ||
|
||
getBody(): unknown { | ||
return msg.producibleMessage.getBody(); | ||
}, | ||
|
||
getTTL(): number { | ||
return msg.producibleMessage.getTTL(); | ||
}, | ||
|
||
getRetryThreshold(): number { | ||
return msg.producibleMessage.getRetryThreshold(); | ||
}, | ||
|
||
getRetryDelay(): number { | ||
return msg.producibleMessage.getRetryDelay(); | ||
}, | ||
|
||
getConsumeTimeout(): number { | ||
return msg.producibleMessage.getConsumeTimeout(); | ||
}, | ||
|
||
getCreatedAt(): number { | ||
return msg.producibleMessage.getCreatedAt(); | ||
}, | ||
|
||
getScheduledRepeat(): number { | ||
return msg.producibleMessage.getScheduledRepeat(); | ||
}, | ||
|
||
getScheduledRepeatPeriod(): number | null { | ||
return msg.producibleMessage.getScheduledRepeatPeriod(); | ||
}, | ||
|
||
getScheduledCRON(): string | null { | ||
return msg.producibleMessage.getScheduledCRON(); | ||
}, | ||
|
||
getScheduledDelay(): number | null { | ||
return msg.producibleMessage.getScheduledDelay(); | ||
}, | ||
|
||
getFanOut(): string | null { | ||
return msg.producibleMessage.getFanOut(); | ||
}, | ||
|
||
getTopic(): TTopicParams | string | null { | ||
return msg.producibleMessage.getTopic(); | ||
}, | ||
|
||
toJSON(): IMessageSerialized { | ||
return msg.toJSON(); | ||
}, | ||
|
||
getExchange(): TExchange { | ||
return msg.getExchange(); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) | ||
* Weyoss <weyoss@protonmail.com> | ||
* https://github.com/weyoss | ||
* | ||
* This source code is licensed under the MIT license found in the LICENSE file | ||
* in the root directory of this source tree. | ||
*/ | ||
|
||
import { ICallback, RedisClient } from 'redis-smq-common'; | ||
import { redisKeys } from '../../common/redis-keys/redis-keys'; | ||
import { EMessageProperty, IMessageStateSerialized } from '../../../types'; | ||
import { MessageNotFoundError } from './errors'; | ||
|
||
export function _getMessageState( | ||
redisClient: RedisClient, | ||
messageId: string, | ||
cb: ICallback<IMessageStateSerialized>, | ||
): void { | ||
const { keyMessage } = redisKeys.getMessageKeys(messageId); | ||
redisClient.hget(keyMessage, String(EMessageProperty.STATE), (err, reply) => { | ||
if (err) cb(err); | ||
else if (!reply) cb(new MessageNotFoundError()); | ||
else cb(null, JSON.parse(reply)); | ||
}); | ||
} |
Oops, something went wrong.