1.0.9 • Published 6 months ago

@jweb-development/butler-aws v1.0.9

Weekly downloads
-
License
-
Repository
github
Last release
6 months ago

Butler

Usage

var butler = require('butler-mq');

Client

Usage

var redis_client = redis.createClient();
var limiter = require('rate-limiting')({redis_client: redis_client});
var client = butler.client(config, limiter); //limiter is optional

putMessage

Puts a message on the queue.

Arguments:

  • options: An object containing the data that will be used to put the message on the queue.

    • queue: The name of the queue the message should be place on.

    • data: The data that should be placed on the queue.

    • push: Options for the push process delay: The actual delay that should be applied to the message. target: The actual target the data should be pushed to. This should be an http endpoint or can be a lambda function. If a lambda function it is in the format lambda://{function_name}. Please note that the lambda function name IS case sensitive. * headers: An object of additional headers to include in the http request. This is only valid if the target is a url.
    • rate_limit: All rate limiting options required if passing in limiter when initalizing client. max_per_second: The rate limit of how many are allowed to output a second. namespace: The namespace used in redis.
  • callback

client.putMessage(options, callback)

Server

Usage

var server = butler.server(config,);

start

Starts the server with the given configuration information.

server.start();

##Description: Amazon SQS Sample Web App in Node.js using Hapi.js, the AWS SDK and other libraries.

Key Technologies:

AWS Elastic Beanstalk Worker AWS Elastic Beanstalk Worker

AWS Elastic Beanstalk is a service used to deploy and scale web application and services. In this particular example I'll be using Node.js for all the work, but other options are available such as Java, .NET, PHP, Python, Ruby and even anything you can stick in a Docker Container. Simply put, you can run whatever you need in Beanstalk and gain all the advantages of the virtualized services and scaling of the toolset.

The worker feature that I'll be using in this how-to, referred to by AWS as Worker Tiers, is setup to handle background tasks at scale. Think of things like doing database cleanup, setting action flags, events, firing triggers or simply sending an email notification. The worker tier that I'll be using, again with Node.js, will simple be there to process messages that I'll put into the queue.

AWS Simple Queue Service (SQS) AWS Simple Queue Service (SQS)

AWS Simple Queue Service, or SQS for short, is a distributed and scalable hosted queue service for storing messages that need to be reliably available between systems. By using SQS I can then create decoupled components of an application that are autonomous of each other in execution. This provides more options around scaling up or scaling down particular workloads, apps and services throughout the application ecosystem that I've built.

For more information on AWS SQS check out this video series by Evan Brown @evandbrown @ Twitter or LinkedIn @ Evan Brown.

AWS Identity and Access Management Permissions (IAM)

When setting up a worker role with Elastic Beanstalk, certain permissions need set to CloudWatch and Elastic Beanstalk can interoperate. To set the permissions an IAM Role needs to be set for the Worker Environment Tiers. For a high level view of IAM check out the AWS IAM Page. For this particular project the specific feature of IAM that is needed is the IAM Roles.