MetaCall Express FaaS RPC Example
An example of building a FaaS server with NodeJS and Express, with a client based on RPC Loader.
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.
-
Install MetaCall:
curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | sh
-
Install dependencies:
metacall npm install
-
In a terminal, run:
$ metacall λ load node server.js
-
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]'
-
In order to close it, in the server terminal write:
λ call close() λ exit