• Stars
    star
    251
  • Rank 161,862 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

For creating distributed jobs using AWS Lambda functions

Hivemind

For creating distributed jobs using AWS Lambda functions.

Install:

npm install lambda-hivemind

Quick Example:

const Hivemind = require('lambda-hivemind')

const hivemind = new Hivemind({
  func: {
    name: 'buzzbuzz',
    handler: 'buzzbuzz.sting',  // '<name of file>.<exported func name>'
    role: '<arn of IAM role to run function under>'
  },
  accessKeyId: '', // AWS credentials. Optional.
  secretAccessKey: '' // AWS credentials. Optional.
  awsRegion: 'us-east-1',
  data: [
    'bee 1',
    'bee 2',
    'bee 3',
    ...
  ],
  chunkSize: 10  // Size of chunks to split data into
})

// Oh no, we haven't published a function of this name yet!

// List all files you want published as your function
hivemind.publish({
  files: [
    'buzzbuzz.js'
  ]
}, {
  // Any AWS parameters specified under http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#createFunction-property
})

hivemind.on('create', () => {
  // Ok, let's go!
  hivemind.run()
})

hivemind.on('finish', (results) => {
  // Each job's results will stream to here.
  console.log("Woah!")
})

hivemind.on('end', () => {
  // All jobs have finished!
  process.exit(0)
})

hivemind.on('error', (err) => {
  console.log("Aww, man!")
})

Methods

constructor(params)

Parameters:

  • func - Description of function
    • name - Name of the function
    • handler (optional) - Handler of function (If your file is named index and your function is named handler, your handler will be index.handler) (default: index.handler)
    • role - ARN of AWS Role to run function under
    • runtime (optional) - What framework to run function with (default: node6.10)
  • lambda (optional) - Overload of AWS Lambda class
  • data - Array of data to run on
  • chunkSize - How many pieces of data to give to each function
  • accessKeyId (optional) - AWS Access key
  • secretAccessKey (optional) - AWS Secret key
  • awsRegion - AWS region to execute your function in

publish(params, awsParams = {})

Publishes or updates specified code as a Lambda function. This method is not required if the function has been previously published and does not need to updated.

Parameters:

  • zipFile - Relative path to ZIP file to publish as function. This method is required if your script has dependencies. See Code.S3Key below if your ZIP is over 10MB.
  • files - Array of relative paths to files to publish
  • lambdaFunc - JavaScript function to publish as your function. The function must use take 3 parameters (event, context, callback). Data is loaded under event, callback is called when function is done.

AWS Parameters:

run()

Chunks and runs data given in constructor through the function specified in constructor and published in publish()

Notes:

AWS credentials in constructor are only optional if you have the AWS CLI configured or have your credentials as environment variables!

Full example can be found under test/ folder.

More Repositories

1

s3-lambda

Lambda functions over S3 objects with concurrency control (each, map, reduce, filter)
JavaScript
1,068
star
2

soil

Simple OpenGL Image Library
C
132
star
3

axis360

Axis360 is a panoramic (360 video) rendering engine
HTML
121
star
4

starplate

Lightning fast template and view engine built on top of Incremental DOM and Babel (ES6 Templates + Incremental DOM working together)
JavaScript
68
star
5

ls-psvr-encoder

A simple command line tool to encode your 180 and 360 videos for sideloading with Littlstar's VR Cinema app for PSVR.
JavaScript
63
star
6

slant

Minimal 360 Video Player
JavaScript
18
star
7

docker-docsify

docsify as a docker (moby) container
Shell
18
star
8

request.cc

Simple HTTP request lib backed by libcurl, inspired by superagent.
C++
11
star
9

stardux

Functional DOM containers based on starplate and redux
JavaScript
10
star
10

littlstar-ios-sdk

Littlstar iOS SDK
Objective-C
9
star
11

lager

A module for collecting data and programmatically flushing it to a single endpoint.
JavaScript
9
star
12

sop

Simple OBJ Parser
C
9
star
13

libgossip

Message queueing in Objective-C without Foundation dependency
Objective-C
9
star
14

rotating-s3-stream

Writable local stream that rotates and syncs to AWS S3 based on max file size or age. Optimized for speed and concurrency.
JavaScript
8
star
15

l3

Dead simple local cdn
JavaScript
8
star
16

orthographic-camera

A high level 3D orthographic camera
JavaScript
6
star
17

pushlytics

Simple server to serve a pixel and record metrics in a LevelDB instance
JavaScript
6
star
18

trim.cc

std::string trim utility
C++
5
star
19

json-struct

validate JSON structures
JavaScript
5
star
20

gqlc

GraphQL Schema Compiler
JavaScript
5
star
21

proposal-did-method-dat

A proposal for a Decentralized Identity (DID) method for the DAT Protocol
4
star
22

dat-did-resolver

DID Method for the DAT Protocol. Resolve a DDO (DID Document) for a DAT.
JavaScript
4
star
23

video-transcode-experiment

C
4
star
24

axis3d-extrude-geometry

JavaScript
4
star
25

ruby-sdk

The official Littlstar Ruby Gem Client Library
Ruby
4
star
26

bpp

Bits-per-pixel calculator
JavaScript
3
star
27

gean

"Composable" Generator Control
JavaScript
3
star
28

three-canvas-renderer

JavaScript
3
star
29

slant-photo

Minimal 360 photo viewer built with three.js.
JavaScript
3
star
30

web-lager

[DEPRECATED] Flexible logger with Express access logging and S3 integration
JavaScript
3
star
31

mlist

Fast lisp like memory lists
JavaScript
3
star
32

chasma

Application Screen Management
JavaScript
3
star
33

acts_as_starable

A gem to add staring functionality to ActiveRecord models
Ruby
3
star
34

git-tree

Tree command scoped to your git project leveraging .gitignore
Shell
3
star
35

clamp

Macro to clamp a value between two other values
C
2
star
36

python-sdk

Littlstar Python SDK
Python
2
star
37

slant-controls

Core video controls API for slant
JavaScript
2
star
38

littlstar.github.io

Littlstar Developer Portal Jekyll Site
CSS
2
star
39

axis3d-orbit-camera

Orbit camera controller for Axis3D
JavaScript
2
star
40

lsplayer-iframe-sdk

Littlstar iframe SDK
JavaScript
2
star
41

slant-player

Slant video player component
JavaScript
2
star
42

regl-examples

Example usage of regl
JavaScript
1
star
43

eslint-config-littlstar

JavaScript
1
star
44

three-vr-effect

THREE.VREffect as a module
JavaScript
1
star
45

wonder3d

A minimal 360 video player
JavaScript
1
star
46

axis3d-inputs

Common user inputs for Axis3D.
JavaScript
1
star
47

redshift-query

Simple function to query Redshift
JavaScript
1
star
48

nrsession

Fetch npm modules and jump into a repl
JavaScript
1
star
49

LSBatch

Batch control flow for Objective-C
Objective-C
1
star
50

persist-store

Syncs file across multiple sources
JavaScript
1
star
51

axis3d-obj-geometry

Converts .OBJ source into an Axis3D Geometry instance.
JavaScript
1
star