{"id":17835001,"url":"https://github.com/carlosedp/zio-temporal-hello","last_synced_at":"2025-03-19T14:31:34.650Z","repository":{"id":141424523,"uuid":"606059134","full_name":"carlosedp/zio-temporal-hello","owner":"carlosedp","description":"Sample hello application using Scala 3 and zio-temporal","archived":false,"fork":false,"pushed_at":"2024-10-14T20:13:48.000Z","size":230,"stargazers_count":15,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-28T19:21:05.738Z","etag":null,"topics":["functional-programming","scala","temporal","zio"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carlosedp.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":"2023-02-24T14:03:27.000Z","updated_at":"2025-02-25T16:12:41.000Z","dependencies_parsed_at":"2024-10-27T20:37:35.960Z","dependency_job_id":"e86e25f5-a20f-424f-9c8e-5088ddc47d18","html_url":"https://github.com/carlosedp/zio-temporal-hello","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosedp%2Fzio-temporal-hello","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosedp%2Fzio-temporal-hello/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosedp%2Fzio-temporal-hello/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosedp%2Fzio-temporal-hello/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carlosedp","download_url":"https://codeload.github.com/carlosedp/zio-temporal-hello/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997127,"owners_count":20380981,"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":["functional-programming","scala","temporal","zio"],"created_at":"2024-10-27T20:16:09.974Z","updated_at":"2025-03-19T14:31:34.378Z","avatar_url":"https://github.com/carlosedp.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZIO - Temporal Sample Application\n\n[![Scala CI](https://github.com/carlosedp/zio-temporal-hello/actions/workflows/scala.yml/badge.svg)](https://github.com/carlosedp/zio-temporal-hello/actions/workflows/scala.yml)\n\nThis is a sample app written in Scala 3, [ZIO Functional Framework](https://zio.dev/) and the [Temporal](https://temporal.io/) platform.\n\nThe idea is to set a modern template project using the latest versions of the following libraries:\n\n- [Scala 3](https://docs.scala-lang.org/scala3/new-in-scala3.html)\n- [Mill build tool](https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html)\n- [Temporal](https://github.com/temporalio/temporal)\n- [ZIO 2](https://github.com/zio/zio)\n- [zio-temporal](https://github.com/vitaliihonta/zio-temporal)\n- [zio-logging](https://zio.dev/ecosystem/officials/zio-logging/)\n- [zio-metrics](https://zio.dev/ecosystem/officials/zio-metrics/)\n- [zio-http](https://github.com/zio/zio-http)\n\n## Organization\n\nThe app have multiple modules:\n\nThe main module is the [`worker`](./worker/src/) which runs the workers that executes the workflows and activities attaching and polling the Temporal queue. It contains the implementation for the workflow and the activities that are executed by the worker.\n\nOne is a command line (CLI) [`client`](./client/src/) that when executed, generates the call to the Temporal workflow.\n\nAnother one is a [`webclient`](./webclient/src/) that starts an HTTP server listening to REST API and proviidng calls to the Temporal workflows.\n\nBoth clients use the shared code to define the workflow interface and also use the definitions in that package to interact with the Temporal server. The code is in the [`shared`](./shared/src/) directory.\n\nThe app uses `zio-http` for the webclient and also to publish Prometheus metrics from `zio-metrics` library.\n\nFor a simple app with only workflows and integrated worker/client, check the [simple](https://github.com/carlosedp/zio-temporal-hello/tree/simple) tag. This is similar to the example from Temporal Java [tutorial](https://learn.temporal.io/getting_started/java/hello_world_in_java).\n\n## Usage\n\nStart the Temporal full stack using the provided docker-compose file:\n\n```sh\ndocker-compose up -d\n\n# To follow the temporal stack logs use\ndocker-compose logs -f\n```\n\nor use [Temporal cli](https://github.com/temporalio/cli) (recommended for development), an \"all-in-one\" binary for Temporal development and testing which is much lighter on resources:\n\n```sh\n# Install with:\ncurl -sSf https://temporal.download/cli.sh | sh\n\n# and run the dev server listening on all IPs (by default, it listens on localhost only)\n$HOME/.temporalio/bin/temporal server start-dev --ip 0.0.0.0 --log-format pretty --log-level warn --db-filename /tmp/temporal.db\n```\n\nRun the workflow worker with:\n\n```sh\n./mill worker.run\n```\n\nAnd on another shell, run the CLI client with:\n\n```sh\n./mill client.run \"My Message\"\n```\n\nTo start the Web client, run:\n\n```sh\n./mill webclient.run\n\n# or during development to watch for changes and re-run, do:\n./mill -w webclient.runBackground\n\n# this can be done for developing any module\n```\n\nThen, submit an API request to the `echo` path which will be sent to the Temporal cluster and returned:\n\n```sh\n❯ curl http://localhost:8083/echo/testmsg\nACK: testmsg%\n```\n\nYou can also use the temporal CLI to start or show the temporal workflow execution:\n\n```sh\n❯ temporal workflow start --type EchoWorkflow --task-queue echo-queue --workflow-id testID01 --input '\"CLI Msg\"'\nRunning execution:\n  WorkflowId  testID01\n  RunId       2cbb72f6-19eb-49ce-85bb-798f0dcb4475\n  Type        EchoWorkflow\n  Namespace   default\n  TaskQueue   echo-queue\n  Args        [\"CLI Msg\"]\n\n\n❯ temporal workflow show -w testID01\nProgress:\n  ID          Time                     Type\n   1  2023-07-05T23:32:50Z  WorkflowExecutionStarted\n   2  2023-07-05T23:32:50Z  WorkflowTaskScheduled\n   3  2023-07-05T23:32:50Z  WorkflowTaskStarted\n   4  2023-07-05T23:32:50Z  WorkflowTaskCompleted\n   5  2023-07-05T23:32:50Z  ActivityTaskScheduled\n   6  2023-07-05T23:32:50Z  ActivityTaskStarted\n   7  2023-07-05T23:32:50Z  ActivityTaskCompleted\n   8  2023-07-05T23:32:50Z  WorkflowTaskScheduled\n   9  2023-07-05T23:32:50Z  WorkflowTaskStarted\n  10  2023-07-05T23:32:51Z  WorkflowTaskCompleted\n  11  2023-07-05T23:32:51Z  WorkflowExecutionCompleted\n\nResult:\n  Status: COMPLETED\n  Output: [\"ACK: CLI Msg\"]\n```\n\nWatch the logs and follow the workflow using the Temporal UI at [http://localhost:8233](http://localhost:8233).\n\nThe worker publishes Prometheus metrics at [http://localhost:8082/metrics](http://localhost:8082/metrics).\n\nThere is also a Python client (to show that clients can be in any language) in the [sample_client.py](./sample_client.py) file. To run it, setup your environment with the `setup_python.sh` script and run the client with:\n\n```sh\npython3 sample_client.py\n```\n\n### Generating Application binaries (GraalVM Native-Image)\n\nThe build can also generate native image binaries for almost instant startup and resource consumption. To generate the binaries, do:\n\n```sh\n# For the worker:\n./mill show worker.nativeImage\n\n# The binary name will be printed at the end:\n...\nProduced artifacts:\n /home/carlosedp/repos/zio-temporal-hello/out/worker/nativeImage.dest/ziotemporalworker (executable)\n /home/carlosedp/repos/zio-temporal-hello/out/worker/nativeImage.dest/ziotemporalworker.build_artifacts.txt (txt)\n========================================================================================================================\nFinished generating 'ziotemporalworker' in 3m 47s.\n\"ref:362fb41c:/home/carlosedp/repos/zio-temporal-hello/out/worker/nativeImage.dest/ziotemporalworker\"\n\n# For the client:\n./mill show client.nativeImage\n\n# and the webclient:\n./mill show webclient.nativeImage\n\n# The binary name will be printed at the end:\n...\nFinished generating 'ziotemporalwebclient' in 4m 26s.\n\"ref:3b33c0f0:/home/carlosedp/repos/zio-temporal-hello/out/webclient/nativeImage.dest/ziotemporalwebclient\"\n```\n\n### Generating Docker images with binary (GraalVM Native-Image)\n\nIt's also possible to generate a Docker image containing the binary for cloud deployment. To generate the images, do:\n\n```sh\n# For the worker:\n./mill worker.dockerNative.build\n\n# The image name will be printed:\n...\n#7 exporting layers 0.5s done\n#7 writing image sha256:b2711446b07e8a89c62c8a4b886652d006e328715e8cdb4e3c2ea9e4014dc92d done\n#7 naming to docker.io/carlosedp/ziotemporal-worker-native done\n#7 DONE 0.5s\n\n# For the webclient:\n./mill webclient.dockerNative.build\n\n# The image name will be printed:\n...\n#7 exporting layers 0.9s done\n#7 writing image sha256:d30fcd5dbb115e015be878c4eff363d95d13c00027c41292a386fe7dbba5f037 done\n#7 naming to docker.io/carlosedp/ziotemporal-webclient-native done\n#7 DONE 0.9s\n```\n\nRun the images with:\n\n```sh\n# Running the worker (Temporal or Temporalite should be running too on another shell)\n# Use your temporal server IP address in the environment variable below\ndocker run -d -e TEMPORAL_SERVER=\"192.168.1.10:7233\" -p 8082:8082 --name ziotemporal-worker docker.io/carlosedp/ziotemporal-worker-native\n\n# Follow the logs with\ndocker logs -f ziotemporal-worker\n\n# Run in a similar way the webclient\ndocker run -d -e TEMPORAL_SERVER=\"192.168.1.10:7233\" -p 8083:8083 --name ziotemporal-webclient docker.io/carlosedp/ziotemporal-webclient-native\n\n# Follow the logs with\ndocker logs -f ziotemporal-webclient\n```\n\nAnd generate requests like the previous section, via web, `temporal` cli or the client modules. Eg. `curl http://192.168.1.10:8083/echo/testmsg`.\n\n## Generating GraalVM Native Image reflection/proxy configs\n\nGraalVM Native image requires reflected and proxied classes to be declared beforehand. This is is eased by the native-image-agent which can be run for the tests with the `NATIVECONFIG_GEN=true` environment variable in the `shared.test` task. This appends to the configs in [./shared/resources/META-INF/native-image](./shared/resources/META-INF/native-image).\n\nAfter using new libraries or updating them, run `NATIVECONFIG_GEN=true ./mill e2e.test`, `NATIVECONFIG_GEN=true ./mill __.test`, `NATIVECONFIG_GEN=true ./mill worker.run`, `NATIVECONFIG_GEN=true ./mill client.run` and create a workflow run manually (via cli or client) to regenerate the native-image reflect/proxy config files.\n\nInitialization arguments which go into [native-image.properties](./shared/resources/META-INF/native-image/native-image.properties) are not generated automatically.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlosedp%2Fzio-temporal-hello","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarlosedp%2Fzio-temporal-hello","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlosedp%2Fzio-temporal-hello/lists"}