Socket
Book a DemoInstallSign in
Socket

cqi-core

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cqi-core

Common Queue Interface inspired by CGI.

0.4.1
latest
Source
npmnpm
Version published
Weekly downloads
7
40%
Maintainers
1
Weekly downloads
 
Created
Source

CQI stands for Common Queue Interface, inspired by CGI.

CQI is a simple and extensible framework to develop queue worker application. It listens message from a queue, and dispatch the messages to an another process through the standard I/O.

The following code listens SQS queue, and executes application.sh for each message. application.sh inputs message body via STDIN, and return the exit code 0 if succeeded.

import { CQI } from '../src/index'

const cqi = CQI.instance
const listener = CQI.factory.listeners.create('sqs', {
  region: 'your-region-1', // Your region
  queueUrl: 'https://sqs.your-region-1.amazonaws.com/ACCOUNT/QUEUE', // Your queueu URL
})

const dispatcher = CQI.factory.dispatchers.create('exec', {
  programFilePath: 'application.sh'
})

cqi.runDefaultContainer(listener, dispatcher)

Component Types

Listener

Listener receive messages from a queue, and passes them to the dispatcher.

  • array Listener to dispatch smessages as string array. (for debugging)
  • repl Listener to dispatch message input from console. (for debugging)
  • sqs Amazon SQS listener.

Dispatcher

Dispatcher passes a queue message from listener to the processer, and decide if successfully consumed.

  • EchoDispatcher Only echo the message.
  • ExecDispatcher CGI style. Starting a new process for each message.
  • StdioDispather Server style. Single process receives messages as lines from STDIN.

ExecDispatcher starts new process for each message, and writes the JSON to STDIN. If the exit status is 0, the message processed successfully.

StdioDispather starts a new process at first, and write each message as a JSON line to STDIN. The process outputs blank line if successfully consumed. Not blank line assumed an error message.

Container

Container joins listener and dispather. There is only one Container.

FAQs

Package last updated on 16 Sep 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.