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

gate-executor

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gate-executor

Execute functions that return via callback in order, but pause if a function is marked as a gate.

  • 0.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.8K
increased by39.91%
Maintainers
1
Weekly downloads
 
Created
Source

gate-executor

Execute functions that return via callback in order, but pause if a function is marked as a gate.

Current Version: 0.2.3

Tested on: Node 0.10, 0.11, 0.12, iojs.

Build Status

Annotated Source

A work execution queue that provides tracing and gating. Work functions can have optional callbacks. Timeouts are triggered when execution does not complete within a specified time.

Gating places execution into a serial mode, where all gated work functions must complete in order before other work functions in the queue are called. The gate can be ignored.

Used by Seneca micro-service communication to execute tasks in order. If you haven't heard about Seneca, check out the getting started guide.

Support

If you're using this module, feel free to contact me on twitter if you have any questions! :) @rjrodger

Gitter chat

Usage

The gate executor provides functionality to pause gated tasks and to quit tasks that exceed a given timeout. The executor can be created with a few options:

var e0 = executor({
  trace: true,              // Error logging trace, default false
  timeout: 150,             // Timout for tasks, default 3333
  error: function() {...},  // A function to wrap all errors in, default noop
  stubs: {		    // Stubs to substitute default node functions
    now: {...},
    setTimeout: {...},
    clearTimeout: {...}
  }
})

When calling the executor with a task, use the following pattern:

e0.execute({
  id: 'a',              // Optional identifier for trace
  fn: function() {...}  // Function to be preformed
  cb: function(err, out) {...}
})

Worker definition

The worker definition object has the following properties:

  • id: an identifier string for the worker.
  • desc: a description string for the worker.
  • fn: the worker function itself; it should accept one argument, a completion callback, which must be called (this in turn then calls the task callback, if any).
  • cb: optional callback function, of the form: function(err,result) { ... }.
  • gate: this worker is a gate; all subsequent workers will wait for this one to complete.
  • ungate: this worker will ignore any gates that are active, and so will be executed regardless.

Testing

npm test

Keywords

FAQs

Package last updated on 09 Jul 2015

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