Skip to content

Repository files navigation

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 BadgeTestCurrent Version


Getting Started

In order to get started using hyper-adapter-queue, you need to setup a hyper instance:

import{defaultasapp}from'https://raw.githubusercontent.com/hyper63/hyper/hyper-app-express%40v1.2.0/packages/app-express/mod.ts'import{defaultashyper}from'https://raw.githubusercontent.com/hyper63/hyper/hyper%40v4.2.0/packages/core/mod.ts'import{defaultasqueue}from'https://raw.githubusercontent.com/hyper63/hyper-adapter-queue/v0.3.0/mod.js'consthyperConfig={
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

consthyper='https://<hyper-host>/queue/<queue-name>'fetch(hyper,{method: 'PUT',body: JSON.stringify({target: 'https://jsonplaceholder.typicode.com/posts',secret: 'shhhh',}),})// { ok: true }

// post a job to the queue

consthyper='https://<hyper-host>/queue/<queue-name>'fetch(hyper,{method: 'POST',body: JSON.stringify({hello: 'world',}),})// { ok: true, id: 123 }

// fetch queued jobs

consthyper='https://<hyper-host>/queue/<queue-name>'+newURLSearchParams({status: 'READY'})fetch(hyper)// { ok: true, jobs: [] }

// fetch errored jobs (DLQ)

consthyper='https://<hyper-host>/queue/<queue-name>'+newURLSearchParams({status: 'ERROR'})fetch(hyper)// { ok: true, jobs: [] }

Testing

Run Tests

deno task test

Run Test Harness

deno task test:harness

Contributing

Contributions are welcome!

License

Apache 2.0

About

in memory queue for local usage

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages