0.0.17 • Published 4 years ago

llend v0.0.17

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

In addition to existing tools, it supports:

  • Dependencies: (install)
  • Importing other files and functions (require)
  • Global variables (vars)

Install

npm i -g llend # install globally

(llend is the former name of DAF.)

Usage

  1. Add annotations in your Monolith code:
// l     
var a = 1;
// lend 

Run via Terminal (Not recommended)

$ llend OPTIONS... 

Options:

  • --fpath PATH: The path to the .js file in which you want to faasify code
  • --linenum NUM: The line number of the // l ... Annotation. Beware, it's 0-indexed.
  • --outpath PATH: The path where the generated FaaS functions will be put (outpath/lambdas/...).
  • --commentout: If specified, the faasified section will be replaced with an Lambda API call. Don't forget to specify //l name(...) before!

Run via Editor Extension

Upcoming: https://github.com/qngapparat/daf-vscode

Output

The tool creates an equivalent Lambda function of that section in [--output]/lambdas/[name]:

└── lambdas
    └── 28723n2398jfs9f87239uhfe9
        ├── index.js
        └── package.json 

You can deploy this function directly to AWS Lambda.

One file can have multiple // l ... // lend sections, that can be converted separately.

Examples

name

You can give your Lambda a name to better keep track of it:

// l name(mylamb)
 var a = 1
// lend
└── lambdas
    └── mylamb
       └── ....
    

vars

Your code might rely on global variables. You can denote them with vars():

var a = 1
// l vars(a)
a++
// lend

The Lambda will automatically unwrap them from the event.

require

Your code might rely on functions from other files. You can import them using require():

// l require(./foo.js as foo)
foo()
// lend

A portable version of foo.js is then included in the deployment package.

└── lambdas
    └── myfunc
       └── foo.js  // <---
       └── ...

If foo in turn depends on other functions or dependencies, they are included as well (recursively). DEVNOTE: This is a very common JS practice, we use Webpack under the hood for this.

install

Your code might depend on NPM packages. You can specify them with install(). They will be included in your deployment package.

// l install(opencv2)
....
// lend

You probably want to import it as well:

// l install(opencv2) require(opencv2)
   opencv2.detectFaces(...)
// lend

return

Your monolith code may have no return statement. To receive something back from the lambda, use return()

// l return(a)  
  var a = 1
  var b = 2
// lend

Advanced Examples

Multiple parameters

With most // l expressions, you can provide a comma-separated list too:

// l vars(a, b, c)
...

Aliasing

You can rename functions and packages, when import them:

// l require(opencv2 as cv)
  cv.detectFaces(...)
// lend

This is obligatory if you import local functions.

Versioning

You can specify the exact versions of the NPM packages to install:

// l install(pkg1@latest, pkg2^1.0.0, pkg3>=1.2.3)
...
// lend

The syntax follows this official schema: https://docs.npmjs.com/misc/semver

0.0.17

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago