Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darnfish/fishqueue
Distributed Express Request Queue
https://github.com/darnfish/fishqueue
queue
Last synced: 15 days ago
JSON representation
Distributed Express Request Queue
- Host: GitHub
- URL: https://github.com/darnfish/fishqueue
- Owner: darnfish
- License: other
- Created: 2020-12-18T13:57:34.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-15T03:51:38.000Z (almost 4 years ago)
- Last Synced: 2024-10-14T04:31:34.770Z (24 days ago)
- Topics: queue
- Language: TypeScript
- Homepage:
- Size: 802 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# fishqueue
![Unit Tests](https://github.com/darnfish/fishqueue/workflows/Unit%20Tests/badge.svg) ![Codecov](https://img.shields.io/codecov/c/gh/darnfish/fishqueue)High-velocity queue for handling incoming Express.js requests across replicated codebase using Redis with minimal residue and maximum buzzwords
## Install
```
yarn add fishqueue
```## Usage
```js
import Queue from 'fishqueue'const queue = new Queue('webhook', { redis: process.env.REDIS_URI, concurrency: 3 })
app.post('/webhook', queue.process(async (req, res) => {
const result = await handleWebHook(req.body)res.send(result)
}))
```### Configuration
Pass an object containing the following properties into the second constructor argument of `Queue`:| Property | Description | Required? | Defaults To |
|-----------------|--------------------------------------------------------------------------------------------------------------------------|-----------|-------------|
| redis | A Redis connection object or URI (see [here](https://github.com/luin/ioredis#connect-to-redis) for more details) | no | `null` |
| verbose | A boolean stating if fishqueue should provide detail logs | no | `false` |
| concurrency | A number stating the amount of concurrent requests to be handled in accordance with `concurrencyType` | no | `3` |
| concurrencyType | A string stating the type of concurrency which should be used. See [Concurrency Types](#concurrency-types) for more info | no | `node` |#### Concurrency Types
| Type | Description |
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| node | Each instance of your app can handle {{ concurrency }} requests at a time. For example, a cluster of 3 nodes with a concurrency of 6 will handle 6 requests per node, totalling 18 requests in processing at any given time |
| cluster | Requests will be handled in a distributed fashion. For example, a cluster of 3 nodes with a concurrency of 6 will handle 2 requests per node |##### Visual Examples
| Node | Cluster_beta_ |
|----------------------------------------|-------------------------------------------|
| | |## License
Do No Harm