Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

hyper63/hyper-adapter-queue

Open more actions menu

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 Badge Test Current Version


Getting Started

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

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

const hyper = '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

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

// fetch queued jobs

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

// fetch errored jobs (DLQ)

const hyper = 'https://<hyper-host>/queue/<queue-name>' + new URLSearchParams({ 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

Packages

 
 
 

Contributors

Generated from hyper63/adapter-template
Morty Proxy This is a proxified and sanitized view of the page, visit original site.