https://github.com/hyper63/hyper-adapter-queue
in memory queue for local usage
https://github.com/hyper63/hyper-adapter-queue
Last synced: about 1 year ago
JSON representation
in memory queue for local usage
- Host: GitHub
- URL: https://github.com/hyper63/hyper-adapter-queue
- Owner: hyper63
- Created: 2021-08-02T12:05:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-11-29T00:26:23.000Z (over 2 years ago)
- Last Synced: 2025-01-13T05:41:38.681Z (about 1 year ago)
- Language: JavaScript
- Size: 155 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
hyper-adapter-queue
The hyper queue service allows the hyper client to create queues,
setting up a webhook endpoint to be invoked everytime a job is posted to the queue.
This service can provide worker push queues to serverless applications, without having
to manage state. This adapter uses an in-memory queue and is designed to work with
local hyper services or services with small workloads.
---
- [Getting Started](#getting-started)
- [Example](#example)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
## Getting Started
In order to get started using `hyper-adapter-queue`, you need to setup a hyper instance:
```js
import { default as app } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper-app-express%40v1.2.0/packages/app-express/mod.ts'
import { default as hyper } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper%40v4.2.0/packages/core/mod.ts'
import { default as queue } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-queue/v0.3.0/mod.js'
const hyperConfig = {
app,
adapters: [
{ port: 'queue', plugins: [queue({ dir: '.', name: 'hyper-queue.db' })] },
],
}
hyper(hyperConfig)
```
> if no options are passed to the adapter, then a sqlite db `hyper-queue.db` will be placed into the
> cwd
## Example
// create a queue
```js
const hyper = 'https:///queue/'
fetch(hyper, {
method: 'PUT',
body: JSON.stringify({
target: 'https://jsonplaceholder.typicode.com/posts',
secret: 'shhhh',
}),
}) // { ok: true }
```
// post a job to the queue
```js
const hyper = 'https:///queue/'
fetch(hyper, {
method: 'POST',
body: JSON.stringify({
hello: 'world',
}),
}) // { ok: true, id: 123 }
```
// fetch queued jobs
```js
const hyper = 'https:///queue/' + new URLSearchParams({ status: 'READY' })
fetch(hyper) // { ok: true, jobs: [] }
```
// fetch errored jobs (DLQ)
```js
const hyper = 'https:///queue/' + new URLSearchParams({ status: 'ERROR' })
fetch(hyper) // { ok: true, jobs: [] }
```
## Testing
Run Tests
```sh
deno task test
```
Run Test Harness
```sh
deno task test:harness
```
## Contributing
Contributions are welcome!
## License
Apache 2.0