An open API service indexing awesome lists of open source software.

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

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.


Nest Badge
Test
Current Version

---

- [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