{"id":28003173,"url":"https://github.com/fnproject/flow-stages","last_synced_at":"2025-10-26T04:33:08.406Z","repository":{"id":25794796,"uuid":"106559847","full_name":"fnproject/flow-stages","owner":"fnproject","description":"Run a machine described in ASL (https://states-language.net/spec.html) as a Fn Flow function.","archived":false,"fork":false,"pushed_at":"2024-01-22T17:18:12.000Z","size":49,"stargazers_count":6,"open_issues_count":5,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-09T01:59:25.631Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/fnproject.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,"zenodo":null}},"created_at":"2017-10-11T13:44:48.000Z","updated_at":"2022-02-10T09:10:32.000Z","dependencies_parsed_at":"2025-05-09T01:59:26.444Z","dependency_job_id":"764e3da6-e5fe-430b-9fd8-5dcef2939be6","html_url":"https://github.com/fnproject/flow-stages","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fnproject/flow-stages","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fflow-stages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fflow-stages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fflow-stages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fflow-stages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnproject","download_url":"https://codeload.github.com/fnproject/flow-stages/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fflow-stages/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274107983,"owners_count":25223472,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-05-09T01:59:22.180Z","updated_at":"2025-10-26T04:33:08.357Z","avatar_url":"https://github.com/fnproject.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fn Flow Stages\n\nFn Flow Stages provides a way of connecting Fn functions in a declarative way, based on the [ASL specification](https://states-language.net/spec.html). This defines a state machine, where a JSON document is passed between labelled states that perform actions depending on the state type and the contents of the document. Fn  Flow Stages is implemented using Fn Flow and the Fn Java FDK.\n\nThere are currently two ways of using Fn Flow Stages:\n\n* The first method uses a machine definition that is packaged alongside the Fn function. The function is called with a JSON document that is passed to the initial state handler, and the machine then transitions between states until it reaches a terminal state (an end, success, or fail state).\n* The second method allows the machine definition to be provided when calling the function. The function is called with an document that defines the machine, and returns a URL. Making an HTTP POST request to this URL with a JSON document starts the machine at the initial state, and progresses in the same way as in the first method described above.\n\n## Instructions \n\n### Prerequisites (from the [Fn Flow user guide](https://github.com/fnproject/fdk-java/blob/master/docs/FnFlowsUserGuide.md#pre-requisites))\n\nBefore you get started, you will need to have the following things:\n\n* Fn CLI\n* Fn Java FDK\n* Fn Flow server\n* Docker-ce 17.06+ installed locally\n* A Docker Hub account\n\n#### Install the Fn CLI tool\n\nTo install the Fn CLI tool, just run the following:\n```bash\n$ curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh\n```\n\nThis will download a shell script and execute it. If the script asks for a password, that is because it invokes sudo.\n\n#### Log in to DockerHub\n\nYou will also need to be logged in to your Docker Hub account in order to deploy functions.\n```bash\n$ docker login\n```\n#### Start a local Fn server and Fn Flow server\n\nIn a terminal, start the functions server:\n```bash\n$ fn start\n```\nSimilarly, start the Fn Flow server and point it at the functions server API URL:\n\n```bash\n$ DOCKER_LOCALHOST=$(docker inspect --type container -f '{{.NetworkSettings.Gateway}}' functions)\n\n$ docker run --rm  \\\n       -p 8081:8081 \\\n       -d \\\n       -e API_URL=\"http://$DOCKER_LOCALHOST:8080/r\" \\\n       -e no_proxy=$DOCKER_LOCALHOST \\\n       --name flow-server \\\n       fnproject/flow:latest\n```\n\n### Running Fn Flow Stages with the packaged machine definition\n\nClone this repo\n```bash\ngit clone https://github.com/fnproject/flow-stages.git\ncd flow-stages\n```\nBuild the function\n```bash\n$ fn build\n```\nAdd a route to the function\n```bash\n$ fn routes create flow /stages\n```\nConfigure the function with the API URL of the Flow server\n```bash\n$ fn apps config set flow COMPLETER_BASE_URL $DOCKER_LOCALHOST\n```\nThe example machine definition provided with Fn Flow Stages (at `./src/main/resources/machine.json`) is a simple counting machine, that calls an incrementing function (`example/increment`) with the value of the `value` field in the document repeatedly, until it is equal to 3, then terminates successfully.\n\nThe incrementing function needs to be built (and a route created to it) before running the machine\n```bash\n$ cd increment\n$ fn build\n$ fn routes create example /increment\n$ cd -\n```\nFinally, the function with a JSON document:\n```bash\n$ echo '{\"value\":1}' | fn call flow /stages\n```\nThe result of the call above should be  `{\"value\": 3}`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnproject%2Fflow-stages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnproject%2Fflow-stages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnproject%2Fflow-stages/lists"}