@rester/queue
TypeScript icon, indicating that this package has built-in type declarations

0.18.8 • Public • Published

Rester Queue

基于 Redis Cluster 的延迟消息队列,GitHub 项目主页

A delay queue based on Redis Cluster, GitHub Project Home.

安装 / Install

npm i -D @rester/queue

快速上手 / Quick Start

创建一个 Broker / Create a Broker

import { ResterBroker } from '@rester/queue';

const broker = new ResterBroker({
  nodes: [
    { port: 7001 },
    { port: 7002 },
    { port: 7003 },
    { port: 7004 },
    { port: 7005 },
    { port: 7006 },
  ],
  config: {
    redisOptions: {
      password: 'rester-redis',
    },
  },
});

发送消息 / Send Message

const delayMessage: Message = {
  topic: 'list',
  body: 'Delay Message',
  delay: 3333,
};
const immediateMessage: Message = {
  topic: 'list',
  body: 'Immediate Message',
};
for (let i = 10; i; i--) {
  queue.produce(immediateMessage);
  queue.produce(delayMessage);
}

接收消息 / Receive Message

logger.info('Start queue.');
const topic = queue.consume({ topic: 'list' });
for await (const message of topic) {
  logger.info('Got message:', JSON.stringify(message));
}

作者 / Authors

IInfinity 夜寒苏, Email, Github, Home Page (Under construction).

许可 / License

THE MIT LICENSE for code.

Copyright © 2018+ Devin Don

LICENSE: MIT

Click https://raw.githubusercontent.com/DevinDon/license/master/THE%20MIT%20LICENSE to view a copy of this license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

THE CC-BY-NC-4.0 LICENSE

Copyright © 2018+ Devin Don

LICENSE: CC BY-NC 4.0

Click https://raw.githubusercontent.com/DevinDon/license/master/THE%20CC%20BY-NC%204.0%20LICENSE to view a copy of this license.

This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.

To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/

or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

Package Sidebar

Install

npm i @rester/queue

Weekly Downloads

0

Version

0.18.8

License

MIT

Unpacked Size

28.5 kB

Total Files

44

Last publish

Collaborators

  • resteradmin
  • devindon