npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lambda-runtime

v0.2.5

Published

Simple logic for dispatching lambdas

Downloads

4

Readme

Lambda Runtime

lambda-runtime

Codeship Status for RebelMail/lambda-runtime

Simple package to allow versioning in AWS Lambdas as well as basic fallback.

Why?

There is no tagging in AWS Lambdas which makes it difficult to have multiple versions of a Lambda running. Think of backwards compatibility with some clients. Also, in the case of a Lambda going down in one AZ you have the ability to call other AZ's until one runs.

Example


var LambdaRouter = require('lambda-runtime');
var lambda = new LambdaRouter(awsKey, awsSecret);

var supportedLambdas = {
  "2015-02-01": "0.0.*",
  "2016-09-01": "1.3.*"
};

var version = supportedLambdas[obj.version];

var lambdaName = "magic";
var env = process.env.NODE_ENV;
var payload = JSON.stringify({});

lambda.invokeAsync(lambdaName, env, version, ['us-east-1', 'us-west-2'], payload, function(err, data) {
  console.log(err, data);
});

Specifications

For the package to perform its function effectively, your lambda names must follow this guideline:

NAME-WITH-WHATEVER-SIZE-YOU-NEED-IT-**ENV**-**MAJOR**-**MINOR**-**PATCH**

Documentation

LambdaRuntime(awsKey, awsSecret)

Returns a LambdaRuntime object.

isValidLambda(lambda, functionName, env, version)

Function used to compare against official Lambdas

  • lambda - Object must have FunctionName defined.
  • functionName - Name to be compared with FunctionName
  • env - Env to be compared with FunctionName
  • version - Version to be comprared with FunctionName

Returns true if the Lambda is compatible with the one being compared with.

latestLambda(lambdas)

  • lambdas - Array of Lambda names. Ex -> ['name-production-0-2-1', 'name-production-0-1-2'];

Returns the lastest definition of the Lambda.

findLatestLambda(functionName, env, version, region, callback)

  • functionName - Lambda name to look for.
  • env - Env to look for.
  • version - Semantic version that should be matched Ex -> (^0.0.x)
  • region - Region to look for.
  • callback(err, lambda) - Will be called with the latest version found.

invokeFallback(lambdas, payload, callback)

  • lambdas - Array of lambdas. Ex -> [null, {name: name-production-0-1-2, region: us-west-2}, {name: name-production-0-1-1, region: us-east-1}]
  • payload - Payload to be invoked.
  • callback(err, result) - If no Errors happened, result can be false or a Lambda object. False implies that no Lambda was accepted.

Once 1 Lambda is successfully executed, the callback will be triggered.

invokeAsync(name, env, version, regions, payload, callback)

  • name - Name of lambda.
  • env - Env of lambda.
  • version - Semantic version to compare against.
  • payload - Payload for lambda.
  • callback(err, lambda) - If no Errors happened, result can be false or a Lambda object. False implies that no Lambda was accepted.

MIT

Enjoy