New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cardstack/queue

Package Overview
Dependencies
Maintainers
5
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cardstack/queue

Job queueing plugin for @cardstack/hub.

  • 0.14.38-patch.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
76
increased by94.87%
Maintainers
5
Weekly downloads
 
Created
Source

Job queuing plugin for Cardstack

This plugin is for queueing jobs with cardstack hub. It uses pg-boss and by extension, postgresql, to manage queued jobs,

Required database configuration

The test suite is configured to talk to a PostgreSQL docker container. You can start it like:

docker run --name cardstack-postgres -d --rm -p 5432:5432 cardstack/pg-test

And stop it like:

docker stop cardstack-postgres

API

Assuming you've looked up the queues feature from DI etc, e.g.

let queue = env.lookup('hub:queues');

You can subscribe to a job by passing in a handler:

queue.subscribe('my-job', handler, options);

Options are passed directly to pg boss.

Handlers can be sync or async:

queue.subscribe('my-job', () => console.log("sync handler") );

queue.subscribe('my-job', () => { return new Promise() } );

queue.subscribe('my-job', async () => { await stuff(); console.log('done') });

You can then publish jobs to the named queues.

To publish without waiting for the job to complete, use the publish method:

  let jobId = await queue.publish('my-job', {someDataForJob: 123}, options);
  // this line executes after the job gets to the db, but before it is executed

To publish and wait for the job to complete, use the publishAndWait method:

  let jobResult = await queue.publishAndWait('my-job', {someDataForJob: 123}, options);
  // this line executes after the job is completed

Keywords

FAQs

Package last updated on 30 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc