2.0.0 • Published 4 years ago

@lifechurch/subserver v2.0.0

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

@lifechurch/subserver

Subserver is a background server process for processing messages from Google Pub/Sub.

Usage

Install

yarn add @lifechurch/subserver @google-cloud/pubsub

Start

import Subserver from '@lifechurch/subserver';
import { handlers } from './handlers';

const handler = message => {
  // perform some action
  message.ack();
};

const config = {
  subscribers: [
    {
      name: 'subscription',
      queue: 'default',
      handler: handler,
    }
  ],
  queue: 'default', // optional
  keepAliveInterval: 1000 * 60 * 60 //optional
};

Subserver.start(config);

Configuration

PropertyTypeDescription
subscribersArrayname: Name of the Subscriptionqueue: Queue to process the Subscription onhandler: Listener function to execute when a message is received
queueStringName of the queue to process the subscription on
livenessPortNumberThe port in which to run the liveness server (Default: 4000)

Local Development

Below is a list of commands you will probably find useful.

yarn build

Bundles the package to the dist folder. The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).

yarn test

Runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.