{"id":14988124,"url":"https://github.com/apache/openwhisk-composer","last_synced_at":"2025-03-22T07:07:29.854Z","repository":{"id":46181868,"uuid":"151100664","full_name":"apache/openwhisk-composer","owner":"apache","description":"Apache OpenWhisk Composer provides a high-level programming model in JavaScript for composing serverless functions","archived":false,"fork":false,"pushed_at":"2024-09-24T14:46:55.000Z","size":1551,"stargazers_count":69,"open_issues_count":6,"forks_count":21,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-14T07:05:27.306Z","etag":null,"topics":["apache","cloud","composer","composition","faas","functions","functions-as-a-service","javascript","node","node-js","nodejs","openwhisk","serverless","serverless-architectures","serverless-functions"],"latest_commit_sha":null,"homepage":"https://openwhisk.apache.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-01T14:17:28.000Z","updated_at":"2025-02-06T20:25:27.000Z","dependencies_parsed_at":"2024-01-25T23:04:29.819Z","dependency_job_id":"57e25973-0510-4fba-83db-2b89d15f97b9","html_url":"https://github.com/apache/openwhisk-composer","commit_stats":{"total_commits":138,"total_committers":15,"mean_commits":9.2,"dds":0.5942028985507246,"last_synced_commit":"188930df36fab9e8490a6e36fabe1a56935f0b73"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fopenwhisk-composer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fopenwhisk-composer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fopenwhisk-composer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fopenwhisk-composer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/openwhisk-composer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244759813,"owners_count":20505709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","cloud","composer","composition","faas","functions","functions-as-a-service","javascript","node","node-js","nodejs","openwhisk","serverless","serverless-architectures","serverless-functions"],"created_at":"2024-09-24T14:16:07.354Z","updated_at":"2025-03-22T07:07:29.816Z","avatar_url":"https://github.com/apache.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n#\n# Licensed to the Apache Software Foundation (ASF) under one or more\n# contributor license agreements.  See the NOTICE file distributed with\n# this work for additional information regarding copyright ownership.\n# The ASF licenses this file to You under the Apache License, Version 2.0\n# (the \"License\"); you may not use this file except in compliance with\n# the License.  You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n--\u003e\n\n# Apache OpenWhisk Composer\n\n[![Travis](https://travis-ci.com/apache/openwhisk-composer.svg?branch=master)](https://travis-ci.com/github/apache/openwhisk-composer)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Join\nSlack](https://img.shields.io/badge/join-slack-9B69A0.svg)](http://slack.openwhisk.org/)\n\nComposer is a new programming model for composing cloud functions built on\n[Apache OpenWhisk](https://github.com/apache/openwhisk). With\nComposer, developers can build even more serverless applications including using\nit for IoT, with workflow orchestration, conversation services, and devops\nautomation, to name a few examples.\n\nComposer synthesizes OpenWhisk [conductor\nactions](https://github.com/apache/openwhisk/blob/master/docs/conductors.md)\nto implement compositions. Compositions have all the attributes and capabilities\nof an action, e.g., default parameters, limits, blocking invocation, web export.\n\nThis repository includes:\n* the [composer](composer.js) Node.js module for authoring compositions using\n  JavaScript,\n* the [compose](bin/compose.js) and [deploy](bin/deploy.js)\n  [commands](docs/COMMANDS.md) for compiling and deploying compositions,\n* [documentation](docs), [examples](samples), and [tests](test).\n\n## Installation\n\nComposer is distributed as Node.js package. To install this package, use the\nNode Package Manager:\n```\nnpm install -g openwhisk-composer\n```\nWe recommend installing the package globally (with `-g` option) if you intend to\nuse the `compose` and `deploy` commands to compile and deploy compositions.\n\n## Defining a composition\n\nA composition is typically defined by means of a JavaScript expression as\nillustrated in [samples/demo.js](samples/demo.js):\n```javascript\nconst composer = require('openwhisk-composer')\n\nmodule.exports = composer.if(\n    composer.action('authenticate', { action: function ({ password }) { return { value: password === 'abc123' } } }),\n    composer.action('success', { action: function () { return { message: 'success' } } }),\n    composer.action('failure', { action: function () { return { message: 'failure' } } }))\n```\nCompositions compose actions using [combinator](docs/COMBINATORS.md) methods.\nThese methods implement the typical control-flow constructs of an imperative\nprogramming language. This example composition composes three actions named\n`authenticate`, `success`, and `failure` using the `composer.if` combinator,\nwhich implements the usual conditional construct. It takes three actions (or\ncompositions) as parameters. It invokes the first one and, depending on the\nresult of this invocation, invokes either the second or third action.\n\n This composition includes the definitions of the three composed actions. If the\n actions are defined and deployed elsewhere, the composition code can be shortened\n to:\n```javascript\ncomposer.if('authenticate', 'success', 'failure')\n```\n\n## Deploying a composition\n\nOne way to deploy a composition is to use the `compose` and `deploy` commands:\n```\ncompose demo.js \u003e demo.json\ndeploy demo demo.json -w\n```\n```\nok: created /_/authenticate,/_/success,/_/failure,/_/demo\n```\nThe `compose` command compiles the composition code to a portable JSON format.\nThe `deploy` command deploys the JSON-encoded composition creating an action\nwith the given name. It also deploys the composed actions if definitions are\nprovided for them. The `-w` option authorizes the `deploy` command to overwrite\nexisting definitions.\n\n## Running a composition\n\nThe `demo` composition may be invoked like any action, for instance using the\nOpenWhisk CLI:\n```\nwsk action invoke demo -p password passw0rd\n```\n```\nok: invoked /_/demo with id 09ca3c7f8b68489c8a3c7f8b68b89cdc\n```\nThe result of this invocation is the result of the last action in the\ncomposition, in this case the `failure` action since the password in incorrect:\n```\nwsk activation result 09ca3c7f8b68489c8a3c7f8b68b89cdc\n```\n```json\n{\n    \"message\": \"failure\"\n}\n```\n### Execution traces\n\nThis invocation creates a trace, i.e., a series of activation records:\n```\nwsk activation list\n```\n\u003cpre\u003e\nDatetime            Activation ID                    Kind     Start Duration   Status  Entity\n2019-03-15 16:43:22 e6bea73bf75f4eb7bea73bf75fdeb703 nodejs:10 warm  1ms        success guest/demo:0.0.1\n2019-03-15 16:43:21 7efb6b7354c3472cbb6b7354c3272c98 nodejs:10 cold  31ms       success guest/failure:0.0.1\n2019-03-15 16:43:21 377cd080f0674e9cbcd080f0679e9c1d nodejs:10 warm  2ms        success guest/demo:0.0.1\n2019-03-15 16:43:20 5dceeccbdc7a4caf8eeccbdc7a9caf18 nodejs:10 cold  29ms       success guest/authenticate:0.0.1\n2019-03-15 16:43:19 66355a1f012d4ea2b55a1f012dcea264 nodejs:10 cold  104ms      success guest/demo:0.0.1\n2019-03-15 16:43:19 09ca3c7f8b68489c8a3c7f8b68b89cdc sequence warm  3.144s     success guest/demo:0.0.1\n\u003c/pre\u003e\n\nThe entry with the earliest start time (`09ca3c7f8b68489c8a3c7f8b68b89cdc`)\nsummarizes the invocation of the composition while other entries record later\nactivations caused by the composition invocation. There is one entry for each\ninvocation of a composed action (`5dceeccbdc7a4caf8eeccbdc7a9caf18` and\n`7efb6b7354c3472cbb6b7354c3272c98`). The remaining entries record the beginning\nand end of the composition as well as the transitions between the composed\nactions.\n\nCompositions are implemented by means of OpenWhisk conductor actions. The\n[documentation of conductor\nactions](https://github.com/apache/openwhisk/blob/master/docs/conductors.md)\nexplains execution traces in greater details.\n\nWhile composer does not limit in principle the length of a composition,\nOpenWhisk deployments typically enforce a limit on the number of action\ninvocations in a composition as well as an upper bound on the rate of\ninvocation. These limits may result in compositions failing to execute to\ncompletion.\n\n## Parallel compositions with Redis\n\nComposer offers parallel combinators that make it possible to run actions or\ncompositions in parallel, for example:\n```javascript\ncomposer.parallel('checkInventory', 'detectFraud')\n```\n\nThe width of parallel compositions is not in principle limited by composer, but\nissuing many concurrent invocations may hit OpenWhisk limits leading to\nfailures: failure to execute a branch of a parallel composition or failure to\ncomplete the parallel composition.\n\nThese combinators require access to a Redis instance to hold intermediate\nresults of parallel compositions. The Redis credentials may be specified at\ninvocation time or earlier by means of default parameters or package bindings.\nThe required parameter is named `$composer`. It is a dictionary with a `redis`\nfield of type dictionary. The `redis` dictionary specifies the `uri` for the\nRedis instance and optionally a certificate as a base64-encoded string to enable\nTLS connections. Hence, the input parameter object for our order-processing\nexample should be:\n```json\n{\n    \"$composer\": {\n        \"redis\": {\n            \"uri\": \"redis://...\",\n            \"ca\": \"optional base64 encoded tls certificate\"\n        }\n    },\n    \"order\": { ... }\n}\n```\n\nThe intent is to store intermediate results in Redis as the parallel composition\nis progressing. Redis entries are deleted after completion and, as an added\nsafety, expire after twenty-four hours.\n\n# OpenWhisk SSL configuration\n\nAdditional configuration is required when using an OpenWhisk instance with\nself-signed certificates to disable SSL certificate validation. The input\nparameter object must contain a parameter of type dictionary named `$composer`.\nThis dictionary must contain a dictionary named `openwhisk`. The `openwhisk`\ndictionary must contain a field named `ignore_certs` with value `true`:\n```json\n{\n    \"$composer\": {\n        \"openwhisk\": {\n            \"ignore_certs\": true\n        }\n    },\n    ...\n}\n```\n\nThis explicit SSL configuration is currently only necessary when using parallel\ncombinators or the `async` combinator.\n\n# Installation from Source\n\nTo install composer from a source release, download the composer source code\nfrom the [Apache OpenWhisk\nDownloads](https://openwhisk.apache.org/downloads.html) page, rename the release\ntarball to `openwhisk-composer.tgz` and install it with command:\n```shell\nnpm install -g openwhisk-composer.tgz\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fopenwhisk-composer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fopenwhisk-composer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fopenwhisk-composer/lists"}