Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@forrestjs/service-fetchq-task

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forrestjs/service-fetchq-task

Simple API to run singleton tasks over a Fetchq queue.

  • 4.7.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
326
increased by7.24%
Maintainers
1
Weekly downloads
 
Created
Source

Fetchq Task

Let you add singleton tasks to a Fetchq queue.

👉 Each task gets executed by one single worker at the time, no matter the horizontal scalability of the queue.

You keep scaling the associated workers as so to run different tasks in parallel.

This is suitable for running stuff akin to a CRON Job.

Configuration

forrest.run({
  settings: {
    fetchq: {
      task: {
        // Register tasks at config time:
        // (see "Add Tasks" paragraph for details)
        register: [
          {
            subject: 'foobar',
            handler: (doc) => doc.reschedule('+1m')
          }
        ],

        queue: {
          // Customize the queue name:
          name: 'foobar',

          // Fine tune the queue performances:
          // https://github.com/fetchq/node-client#queues-configuration
          settings: {}
        },
        
        worker: {
          // Fine tune the worker performances:
          // https://github.com/fetchq/node-client#workers-configuration
          settings: {}
        }
      }
    }
  }
})

Add Tasks

As configuration:

forrest.run({
  settings: {
    fetchq: {
      task: {
        register: [
          {
            // Document in the tasks' queue:
            subject: "cqrs-todos",
            payload: { target: "todos" },
            // Worker for this specific task:
            handler: (doc, ctx) => {
              console.log("cqrs-todos", doc.payload);
              return doc.reschedule("+1s");
            }
          }
        ]
      }
    }
  }
})

As an extension:

const myFeature = () => [
  {
    target: "$FETCHQ_REGISTER_TASK",
    handler: {
      // Document in the tasks' queue:
      subject: "cqrs-todos",
      payload: { target: "todos" },
      // Worker for this specific task:
      handler: (doc, ctx) => {
        console.log("cqrs-todos", doc.payload);
        return doc.reschedule("+1s");
      }
    }
  }
]

Task Configuration

resetOnBoot

Set it to true and the task will be completely reset at boot time.

Keywords

FAQs

Package last updated on 21 Sep 2022

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