metacall / express-faas-rpc-example

How to write a FaaS in NodeJS with less than 100LoC by using MetaCall.

Home Page:https://metacall.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MetaCall Express FaaS RPC Example

An example of building a FaaS server with NodeJS and Express, with a client based on RPC Loader.

Architecture

This example shows how to implement a server offering FaaS facilities by using MetaCall with NodeJS, the RPC calls from client look like normal function calls.

Run it

  1. Install MetaCall:

    curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | sh
  2. Install dependencies:

    metacall npm install
  3. In a terminal, run:

    $ metacall
    λ load node server.js
  4. In another terminal, run:

    metacall client.js

    Or optionally, with CURL:

    curl -X POST -H 'Content-type: application/json' http://localhost:3051/call/sum --data '[3, 4]'
    curl -X POST -H 'Content-type: application/json' http://localhost:3051/call/mult --data '[2, 3]'
  5. In order to close it, in the server terminal write:

    λ call close()
    λ exit

About

How to write a FaaS in NodeJS with less than 100LoC by using MetaCall.

https://metacall.io

License:Apache License 2.0


Languages

Language:JavaScript 97.3%Language:Ruby 1.4%Language:Python 1.3%