{"id":18930159,"url":"https://github.com/nheidloff/openwhisk-polyglot","last_synced_at":"2025-04-15T15:31:20.487Z","repository":{"id":88375218,"uuid":"125530866","full_name":"nheidloff/openwhisk-polyglot","owner":"nheidloff","description":"Serverless Polyglot Application based on Apache OpenWhisk","archived":false,"fork":false,"pushed_at":"2018-03-21T15:05:15.000Z","size":6100,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T22:51:11.986Z","etag":null,"topics":["ibm","java","javascript","kotlin","openwhisk","polyglot","serverless","typescript"],"latest_commit_sha":null,"homepage":"","language":"Java","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/nheidloff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-03-16T14:55:57.000Z","updated_at":"2019-09-27T03:00:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3eab7f9-be5f-4f1c-b396-52a5e27f6456","html_url":"https://github.com/nheidloff/openwhisk-polyglot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-polyglot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-polyglot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-polyglot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-polyglot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nheidloff","download_url":"https://codeload.github.com/nheidloff/openwhisk-polyglot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249097910,"owners_count":21212376,"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":["ibm","java","javascript","kotlin","openwhisk","polyglot","serverless","typescript"],"created_at":"2024-11-08T11:36:48.217Z","updated_at":"2025-04-15T15:31:20.475Z","avatar_url":"https://github.com/nheidloff.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenWhisk Polyglot Application\n\nThis project contains samples how to develop functions for [Apache OpenWhisk](https://openwhisk.apache.org/) with JavaScript, TypeScript, Java, Kotlin and Docker. \n\nWhile functions are stateless, applications defined with [Composer](https://github.com/ibm-functions/composer) manage the state and are responsible how the data flows between the functions. \n\nThis project contains a sample polyglot application to send either mails or text messages to certain users dependent on which information have provided in their profiles.\n\nHere is the data flow used in this sample to send a notification:\n\n* The application is triggered with a person id and a subject. \n* The function 'read-person-profile' returns the profile for the specific user. The profile contains email addresses and can contain phone numbers.\n* If the profile has a phone number, the function 'send-text-message' is invoked, otherwise the funtion 'send-mail'.\n* The other functions transfer the data in the format expected by the loosely coupled business logic functions.\n\n![alt text](screenshots/flow-polyglot.png \"OpenWhisk\")\n\n\n### Prerequisites\n\n* [OpenWhisk CLI](https://github.com/apache/incubator-openwhisk-cli)\n* [IBM Cloud Account](https://ibm.biz/nheidloff)\n* [IBM Cloud CLI](https://clis.ng.bluemix.net/)\n* [Composer CLI](https://github.com/ibm-functions/composer/tree/master/docs#installing-the-shell) and Redis\n* [Docker](https://docs.docker.com/engine/installation/)\n* [git](https://git-scm.com/downloads)\n\nFor JavaScript and TypeScript install these additional tools:\n\n* [Visual Studio Code](https://code.visualstudio.com/)\n* [Node](https://nodejs.org/en/download/)\n\nFor Kotlin install these additional tools:\n\n* [Java JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html)\n* [IntelliJ IDEA Community](https://www.jetbrains.com/idea/download/)\n* [Gradle](https://gradle.org/)\n\nFor Java install these additional tools:\n\n* [Java JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html)\n* [Eclipse Java EE IDE for Web Developers](https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/oxygen3rc2)\n* [Maven](https://maven.apache.org/install.html)\n\n\n## Setup\n\nRun these commands to login to IBM Cloud and to create a namespace:\n\n```sh\n$ git clone https://github.com/nheidloff/openwhisk-polyglot.git\n$ cd openwhisk-polyglot\n$ bx login -a api.ng.bluemix.net \n$ bx target --cf\n$ wsk package create polyglot-demo-nh\n```\n\nRun these commands to build and deploy the JavaScript functions:\n\n```sh\n$ wsk action update polyglot-demo-nh/transform-read-person-profile functions/javascript/transform-read-person-profile.js\n$ wsk action update polyglot-demo-nh/transform-send-text-message functions/javascript/transform-send-text-message.js\n$ cd functions/javascript\n$ npm install\n$ zip -rq transformsendmail.zip transform-send-mail.js package.json node_modules\n$ wsk action update polyglot-demo-nh/transform-send-mail --kind nodejs:8 transformsendmail.zip\n$ cd ../..\n```\n\nRun these commands to build and deploy the TypeScript function:\n\n```sh\n$ cd functions/typescript\n$ npm install\n$ npm run postinstall\n$ docker build -t \u003cdockerhub-name\u003e/openwhisk-docker-typescript-polyglot:latest .\n$ docker push \u003cdockerhub-name\u003e/openwhisk-docker-typescript-polyglot\n$ bx wsk action update polyglot-demo-nh/read-person-profile --docker \u003cdockerhub-name\u003e/openwhisk-docker-typescript-polyglot:latest\n```\n\nRun these commands to build and deploy the Java function:\n\n```sh\n$ cd functions/java/spring\n$ mvn clean install\n$ cd ..\n$ docker build -t \u003cdockerhub-name\u003e/openwhisk-docker-spring-boot-polyglot:latest .\n$ docker push \u003cdockerhub-name\u003e/openwhisk-docker-spring-boot-polyglot\n$ bx wsk action update polyglot-demo-nh/send-mail --docker \u003cdockerhub-name\u003e/openwhisk-docker-spring-boot-polyglot:latest\n```\n\nYou also need to increase the memory and timeout settings.\n\nRun these commands to build and deploy the Kotlin function:\n\n```sh\n$ cd functions/kotlin/kotlin\n$ gradle build jar\n$ cd ..\n$ docker build -t \u003cdockerhub-name\u003e/openwhisk-docker-kotlin-polyglot:latest .\n$ docker push \u003cdockerhub-name\u003e/openwhisk-docker-kotlin-polyglot\n$ bx wsk action update polyglot-demo-nh/send-text-message --docker \u003cdockerhub-name\u003e/openwhisk-docker-kotlin-polyglot:latest\n```\n\nRun this command to create the application:\n\n```sh\n$ fsh app update polyglot-demo-nh/send-notification app/app.js\n```\n\nTo run the application invoke these commands:\n\n```sh\n$ fsh app invoke polyglot-demo-nh/send-notification -p id nheidloff -p subject Hello\n$ fsh app invoke polyglot-demo-nh/send-notification -p id mark -p subject Hello\n```\n\nHere is sample output of the application:\n\n![alt text](screenshots/session-result.png \"OpenWhisk\")\n\n\n## Run Functions Locally\n\nThe JavaScript and TypeScript functions can be run and debugged locally as documented in the project [openwhisk-debug-nodejs](https://github.com/nheidloff/openwhisk-debug-nodejs).\n\n### TypeScript\n\nTo run the TypeScript function in a container, open the project in Microsoft Visual Studio Code and run the launch configurations 'typescript function'. After the container has been launched you can invoke the function via this command:\n\n```sh\ncurl --request POST \\\n  --url http://localhost:8080/run \\\n  --header 'Cache-Control: no-cache' \\\n  --header 'Content-Type: application/json' \\\n  --data '{ \"value\": {\"id\":\"nheidloff\",\"subject\":\"Hello\"}}'\n```\n\nAfter you're done stop the container via these commands:\n\n```sh\n$ cd functions/typescript\n$ docker-compose down\n```\n\n\n### Java\n\nRun these commands to run the Spring Boot function in a Docker container:\n\n```sh\n$ cd functions/java/spring\n$ mvn clean build\n$ cd ..\n$ docker build -t openwhisk-docker-spring-boot:latest .\n$ docker run -p 8080:8080 --rm=true openwhisk-docker-spring-boot:latest\n$ curl --request POST \\\n  --url http://localhost:8080/run \\\n  --header 'Cache-Control: no-cache' \\\n  --header 'Content-Type: application/json' \\\n  --data '{ \"value\": {\"input\":{\"email\":\"aaaaa@gmail.com\",\"subject\":\"Hello\"}}}'\n```\n\n\n### Kotlin\n\nRun these commands to run the Kotlin function in a Docker container:\n\n```sh\n$ cd functions/kotlin/kotlin\n$ gradle build clean\n$ cd ..\n$ docker build -t openwhisk-docker-kotlin:latest .\n$ docker run -p 8080:8080 --rm=true openwhisk-docker-kotlin:latest\n$ curl --request POST \\\n  --url http://localhost:8080/run \\\n  --header 'Cache-Control: no-cache' \\\n  --header 'Content-Type: application/json' \\  \n  --data '{ \"value\": {\"input\":{\"phone\":\"+4900\",\"subject\":\"Hello\"}}}'\n```\n\n\n## More Information\n\nFor more information check out these articles on my blog:\n\n* [Debugging Apache OpenWhisk Functions with VS Code](http://heidloff.net/article/debug-apache-openwhisk-functions-vscode)\n* [Developing Serverless Functions with TypeScript](http://heidloff.net/article/serverless-functions-typescript-openwhisk)\n* [Developing OpenWhisk Functions with Kotlin in IntelliJ](http://heidloff.net/article/openwhisk-kotlin-intellij-docker)\n* [Developing OpenWhisk Functions with Spring Boot](http://heidloff.net/article/openwhisk-spring-boot-eclipse)\n* [Data Flows in Serverless Cloud-Native Applications](http://heidloff.net/article/serverless-data-flows)\n* [Transforming JSON Data in Serverless Applications](http://heidloff.net/article/transforming-json-serverless)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnheidloff%2Fopenwhisk-polyglot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnheidloff%2Fopenwhisk-polyglot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnheidloff%2Fopenwhisk-polyglot/lists"}