{"id":28820666,"url":"https://github.com/64j0/poc--postgres-trigger-program","last_synced_at":"2026-05-16T11:06:16.933Z","repository":{"id":298400218,"uuid":"906437330","full_name":"64J0/poc--postgres-trigger-program","owner":"64J0","description":"POC for using Postgres to trigger a program execution leveraging F#'s native MailboxProcessor","archived":false,"fork":false,"pushed_at":"2025-06-10T22:44:33.000Z","size":101,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-10T23:32:30.530Z","etag":null,"topics":["api","distributed-systems","fsharp","giraffe","mailbox-processor","postgres"],"latest_commit_sha":null,"homepage":"","language":"F#","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/64J0.png","metadata":{"files":{"readme":"README.org","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":"2024-12-20T23:02:42.000Z","updated_at":"2025-06-10T22:44:36.000Z","dependencies_parsed_at":"2025-06-10T23:42:38.544Z","dependency_job_id":null,"html_url":"https://github.com/64J0/poc--postgres-trigger-program","commit_stats":null,"previous_names":["64j0/poc--postgres-trigger-program"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/64J0/poc--postgres-trigger-program","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc--postgres-trigger-program","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc--postgres-trigger-program/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc--postgres-trigger-program/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc--postgres-trigger-program/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/64J0","download_url":"https://codeload.github.com/64J0/poc--postgres-trigger-program/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64J0%2Fpoc--postgres-trigger-program/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260640636,"owners_count":23040495,"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":["api","distributed-systems","fsharp","giraffe","mailbox-processor","postgres"],"created_at":"2025-06-18T22:00:42.974Z","updated_at":"2025-10-15T05:17:24.749Z","avatar_url":"https://github.com/64J0.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE: [POC] Postgres trigger program\n#+DATE: [2024-12-26 qui]\n\nThe idea of this POC project is to create a multi-service application composed\nof:\n\n- 1. An HTTP Rest API to interact with the user to set scripts that are going to\n  be run in the background,\n- 2. A Postgres database to store the data (application's source of truth) that\n  is also responsible for communicating the background application about new\n  script execution requests,\n- 3. A background application leveraging a MailboxProcessor that is notified by\n  the database whenever a new ~program_execution~ entity is created and it's\n  used to run the specified program, collect its output and update the database\n  accordingly.\n\nOther than this, when using the API the user will be able to:\n\n- [X] Register new scripts;\n- [X] List scripts that are already registered;\n- [ ] Get the script execution results.\n\n** How to run with containers\n\n#+BEGIN_SRC bash :tangle no\n  # start the containerized project\n  make compose-up\n\n  # start playing with the API and check the logs from the manager process\n  curl \\\n    -d '{\"programName\":\"placeholder_001\"}' \\\n    -H \"Content-Type: application/json\" \\\n    -X POST \\\n    http://localhost:5000/api/program\n\n  curl http://localhost:5000/api/programs\n\n  # upload the script (change the necessary details at the following command):\n  curl --request PATCH \\\n  --url http://localhost:5000/api/program/PROGRAM_ID_GUID \\\n  --header 'Content-Type: multipart/form-data' \\\n  --form script=@/YOUR_LOCAL_PATH/samples/wait.fsx\n\n  curl \\\n    -d '{\"programInput\":\"100\"}' \\\n    -H \"Content-Type: application/json\" \\\n    -X POST \\\n    http://localhost:5000/api/execution/PROGRAM_ID_GUID\n\n  # check the database and the container logs\n#+END_SRC\n\n** How to run with dotnet CLI\n\n#+BEGIN_SRC bash :tangle no\n  # 1st shell\n  #\n  # start the database container with\n  docker compose up -d postgres\n\n  # if you need to restart it use\n  #\n  # docker compose down\n  # docker compose up -d postgres\n  #\n  # check the logs with\n  #\n  # docker container logs -f postgres_container\n\n  # Start the API with\n  dotnet run --define:DEBUG --project api/\n\n  # ===============================================\n  # 2nd shell\n  #\n  # start the manager process\n  dotnet run --define:DEBUG --project manager/\n\n  # ===============================================\n  # 3rd shell\n  #\n  # start playing with the API and check the logs from the manager process\n  curl \\\n    -d '{\"programName\":\"placeholder_001\"}' \\\n    -H \"Content-Type: application/json\" \\\n    -X POST \\\n    http://localhost:5000/api/program\n\n  curl http://localhost:5000/api/programs\n\n  # upload the script (change the necessary details at the following command):\n  curl --request PATCH \\\n  --url http://localhost:5000/api/program/PROGRAM_ID_GUID \\\n  --header 'Content-Type: multipart/form-data' \\\n  --form script=@/YOUR_LOCAL_PATH/samples/get_date.fsx\n\n  curl \\\n    -d '{\"programInput\":\"1 2 3\"}' \\\n    -H \"Content-Type: application/json\" \\\n    -X POST \\\n    http://localhost:5000/api/execution/PROGRAM_ID_GUID\n\n  curl http://localhost:5000/api/executions\n#+END_SRC\n\n** Useful links\n\n- *POSTGRES:*\n  - https://www.postgresql.org/docs/current/sql-notify.html\n  - https://www.npgsql.org/doc/wait.html\n  - https://tedeh.net/publishing-rabbitmq-messages-from-postgresql/\n- *F#:*\n  - https://thesharperdev.com/fsharps-mailboxprocessor/\n  - https://en.wikibooks.org/wiki/F_Sharp_Programming/MailboxProcessor\n  - https://fsharpforfunandprofit.com/posts/concurrency-actor-model/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F64j0%2Fpoc--postgres-trigger-program","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F64j0%2Fpoc--postgres-trigger-program","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F64j0%2Fpoc--postgres-trigger-program/lists"}