All Projects → ibm-functions → Composer

ibm-functions / Composer

Licence: apache-2.0
Composer is a new programming model for composing cloud functions built on Apache OpenWhisk.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Composer

Openwhisk Cli
Apache OpenWhisk Command Line Interface (CLI)
Stars: ✭ 73 (-44.27%)
Mutual labels:  serverless, faas, functions
Openwhisk Runtime Nodejs
Apache OpenWhisk Runtime NodeJS supports Apache OpenWhisk functions written in JavaScript for NodeJS
Stars: ✭ 43 (-67.18%)
Mutual labels:  serverless, faas, functions
Faas Netes
Serverless on Kubernetes with OpenFaaS
Stars: ✭ 1,875 (+1331.3%)
Mutual labels:  serverless, faas, functions
Gofn
Function process via docker provider (serverless minimalist)
Stars: ✭ 134 (+2.29%)
Mutual labels:  serverless, faas, functions
Openwhisk
Apache OpenWhisk is an open source serverless cloud platform
Stars: ✭ 5,499 (+4097.71%)
Mutual labels:  serverless, faas, functions
Mongodb Function
OpenFaaS Function that makes use of a connection pool to access MongoDB
Stars: ✭ 44 (-66.41%)
Mutual labels:  serverless, faas, functions
Faas
OpenFaaS - Serverless Functions Made Simple
Stars: ✭ 20,820 (+15793.13%)
Mutual labels:  serverless, faas, functions
Openwhisk Devtools
Development tools for building and deploying Apache OpenWhisk
Stars: ✭ 141 (+7.63%)
Mutual labels:  serverless, faas, functions
Dispatch
Dispatch is a framework for deploying and managing serverless style applications.
Stars: ✭ 529 (+303.82%)
Mutual labels:  serverless, faas, functions
Microcule
SDK and CLI for spawning streaming stateless HTTP microservices in multiple programming languages
Stars: ✭ 454 (+246.56%)
Mutual labels:  serverless, faas, functions
Openwhisk Deploy Kube
The Apache OpenWhisk Kubernetes Deployment repository supports deploying the Apache OpenWhisk system on Kubernetes and OpenShift clusters.
Stars: ✭ 231 (+76.34%)
Mutual labels:  serverless, faas, functions
Graphql Serverless
GraphQL (incl. a GraphiQL interface) middleware for the webfunc serverless web framework.
Stars: ✭ 124 (-5.34%)
Mutual labels:  serverless, faas, functions
Nuclio
High-Performance Serverless event and data processing platform
Stars: ✭ 4,213 (+3116.03%)
Mutual labels:  serverless, faas, functions
Fission
Fast and Simple Serverless Functions for Kubernetes
Stars: ✭ 6,646 (+4973.28%)
Mutual labels:  serverless, faas, functions
Openwhisk Runtime Php
Apache OpenWhisk Runtime PHP supports Apache OpenWhisk functions written in PHP
Stars: ✭ 26 (-80.15%)
Mutual labels:  serverless, faas, functions
Fx
A Function as a Service tool makes a function as a container-based service in seconds.
Stars: ✭ 1,679 (+1181.68%)
Mutual labels:  serverless, faas
Openwhisk Apigateway
Apache OpenWhisk API Gateway service for exposing actions as REST interfaces.
Stars: ✭ 56 (-57.25%)
Mutual labels:  serverless, faas
Alagarr
🦍 Alagarr is a request-response helper library that removes the boilerplate from your Node.js (AWS Lambda) serverless functions and helps make your code portable.
Stars: ✭ 58 (-55.73%)
Mutual labels:  serverless, faas
Apex
Old apex/apex
Stars: ✭ 20 (-84.73%)
Mutual labels:  serverless, faas
Community Cluster
OpenFaaS Cloud Cluster for Community
Stars: ✭ 59 (-54.96%)
Mutual labels:  serverless, faas

@ibm-functions/composer

Travis License Join Slack

Composer is a new programming model for composing cloud functions built on Apache OpenWhisk. With Composer, developers can build even more serverless applications including using it for IoT, with workflow orchestration, conversation services, and devops automation, to name a few examples.

Composer synthesizes OpenWhisk conductor actions to implement compositions. Compositions have all the attributes and capabilities of an action, e.g., default parameters, limits, blocking invocation, web export.

This repository includes:

Installation

Composer is distributed as Node.js package. To install this package, use the Node Package Manager:

npm install -g @ibm-functions/composer

We recommend installing the package globally (with -g option) if you intend to use the compose and deploy commands to compile and deploy compositions.

Defining a composition

A composition is typically defined by means of a JavaScript expression as illustrated in samples/demo.js:

const composer = require('@ibm-functions/composer')

module.exports = composer.if(
    composer.action('authenticate', { action: function ({ password }) { return { value: password === 'abc123' } } }),
    composer.action('success', { action: function () { return { message: 'success' } } }),
    composer.action('failure', { action: function () { return { message: 'failure' } } }))

Compositions compose actions using combinator methods. These methods implement the typical control-flow constructs of an imperative programming language. This example composition composes three actions named authenticate, success, and failure using the composer.if combinator, which implements the usual conditional construct. It takes three actions (or compositions) as parameters. It invokes the first one and, depending on the result of this invocation, invokes either the second or third action.

This composition includes the definitions of the three composed actions. If the actions are defined and deployed elsewhere, the composition code can be shortened to:

composer.if('authenticate', 'success', 'failure')

Deploying a composition

One way to deploy a composition is to use the compose and deploy commands:

compose demo.js > demo.json
deploy demo demo.json -w
ok: created /_/authenticate,/_/success,/_/failure,/_/demo

The compose command compiles the composition code to a portable JSON format. The deploy command deploys the JSON-encoded composition creating an action with the given name. It also deploys the composed actions if definitions are provided for them. The -w option authorizes the deploy command to overwrite existing definitions.

Running a composition

The demo composition may be invoked like any action, for instance using the IBM Cloud CLI:

ibmcloud fn action invoke demo -p password passw0rd
ok: invoked /_/demo with id 09ca3c7f8b68489c8a3c7f8b68b89cdc

The result of this invocation is the result of the last action in the composition, in this case the failure action since the password in incorrect:

ibmcloud fn activation result 09ca3c7f8b68489c8a3c7f8b68b89cdc
{
    "message": "failure"
}

Execution traces

This invocation creates a trace, i.e., a series of activation records:

ibmcloud fn activation list
Datetime            Activation ID                    Kind     Start Duration   Status  Entity
2019-03-15 16:43:22 e6bea73bf75f4eb7bea73bf75fdeb703 nodejs:10 warm  1ms        success guest/demo:0.0.1
2019-03-15 16:43:21 7efb6b7354c3472cbb6b7354c3272c98 nodejs:10 cold  31ms       success guest/failure:0.0.1
2019-03-15 16:43:21 377cd080f0674e9cbcd080f0679e9c1d nodejs:10 warm  2ms        success guest/demo:0.0.1
2019-03-15 16:43:20 5dceeccbdc7a4caf8eeccbdc7a9caf18 nodejs:10 cold  29ms       success guest/authenticate:0.0.1
2019-03-15 16:43:19 66355a1f012d4ea2b55a1f012dcea264 nodejs:10 cold  104ms      success guest/demo:0.0.1
2019-03-15 16:43:19 09ca3c7f8b68489c8a3c7f8b68b89cdc sequence warm  3.144s     success guest/demo:0.0.1

The entry with the earliest start time (09ca3c7f8b68489c8a3c7f8b68b89cdc) summarizes the invocation of the composition while other entries record later activations caused by the composition invocation. There is one entry for each invocation of a composed action (5dceeccbdc7a4caf8eeccbdc7a9caf18 and 7efb6b7354c3472cbb6b7354c3272c98). The remaining entries record the beginning and end of the composition as well as the transitions between the composed actions.

Compositions are implemented by means of OpenWhisk conductor actions. The documentation of conductor actions explains execution traces in greater details.

While composer does not limit in principle the length of a composition, OpenWhisk deployments typically enforce a limit on the number of action invocations in a composition as well as an upper bound on the rate of invocation. These limits may result in compositions failing to execute to completion.

Parallel compositions with Redis

Composer offers parallel combinators that make it possible to run actions or compositions in parallel, for example:

composer.parallel('checkInventory', 'detectFraud')

The width of parallel compositions is not in principle limited by composer, but issuing many concurrent invocations may hit OpenWhisk limits leading to failures: failure to execute a branch of a parallel composition or failure to complete the parallel composition.

These combinators require access to a Redis instance to hold intermediate results of parallel compositions. The Redis credentials may be specified at invocation time or earlier by means of default parameters or package bindings. The required parameter is named $composer. It is a dictionary with a redis field of type dictionary. The redis dictionary specifies the uri for the Redis instance and optionally a certificate as a base64-encoded string to enable TLS connections. Hence, the input parameter object for our order-processing example should be:

{
    "$composer": {
        "redis": {
            "uri": "redis://...",
            "ca": "optional base64 encoded tls certificate"
        }
    },
    "order": { ... }
}

The intent is to store intermediate results in Redis as the parallel composition is progressing. Redis entries are deleted after completion and, as an added safety, expire after twenty-four hours.

OpenWhisk SSL configuration

Additional configuration is required when using an OpenWhisk instance with self-signed certificates to disable SSL certificate validation. The input parameter object must contain a parameter of type dictionary named $composer. This dictionary must contain a dictionary named openwhisk. The openwhisk dictionary must contain a field named ignore_certs with value true:

{
    "$composer": {
        "openwhisk": {
            "ignore_certs": true
        }
    },
    ...
}

This explicit SSL configuration is currently only necessary when using parallel combinators or the async combinator.

Installation from Source

To install composer from a source release, download the composer source code from our GitHub repo, rename the release tarball to composer.tgz and install it with command:

npm install -g composer.tgz
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].