{"id":23613647,"url":"https://github.com/freckle/faktory_worker_haskell","last_synced_at":"2025-05-12T21:40:42.426Z","repository":{"id":42621044,"uuid":"133517830","full_name":"freckle/faktory_worker_haskell","owner":"freckle","description":"Faktory Worker for Haskell","archived":false,"fork":false,"pushed_at":"2025-03-31T22:54:41.000Z","size":267,"stargazers_count":17,"open_issues_count":3,"forks_count":2,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-05-06T13:58:02.192Z","etag":null,"topics":["faktory","ghvm-managed","haskell"],"latest_commit_sha":null,"homepage":"","language":"Haskell","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/freckle.png","metadata":{"files":{"readme":"README.lhs","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-15T13:10:13.000Z","updated_at":"2025-04-09T10:12:56.000Z","dependencies_parsed_at":"2024-04-09T18:50:30.056Z","dependency_job_id":"73a4e635-223a-4e20-9ace-5de44be0381e","html_url":"https://github.com/freckle/faktory_worker_haskell","commit_stats":null,"previous_names":["frontrowed/faktory_worker_haskell"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freckle%2Ffaktory_worker_haskell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freckle%2Ffaktory_worker_haskell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freckle%2Ffaktory_worker_haskell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freckle%2Ffaktory_worker_haskell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freckle","download_url":"https://codeload.github.com/freckle/faktory_worker_haskell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253826710,"owners_count":21970402,"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":["faktory","ghvm-managed","haskell"],"created_at":"2024-12-27T17:18:36.394Z","updated_at":"2025-05-12T21:40:42.364Z","avatar_url":"https://github.com/freckle.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# faktory\\_worker\\_haskell\n\n[![Hackage](https://img.shields.io/hackage/v/faktory.svg?style=flat)](https://hackage.haskell.org/package/faktory)\n[![Stackage Nightly](http://stackage.org/package/faktory/badge/nightly)](http://stackage.org/nightly/package/faktory)\n[![Stackage LTS](http://stackage.org/package/faktory/badge/lts)](http://stackage.org/lts/package/faktory)\n[![CI](https://github.com/freckle/faktory_worker_haskell/actions/workflows/ci.yml/badge.svg)](https://github.com/freckle/faktory_worker_haskell/actions/workflows/ci.yml)\n\nHaskell client and worker process for the Faktory background job server.\n\nArchitecture overview from [Ruby client README](https://github.com/contribsys/faktory_worker_ruby#readme):\n\n```\n                       +--------------------+\n                       |                    |\n                       |     Faktory        |\n                       |     Server         |\n        +----------\u003e\u003e\u003e\u003e|                    +\u003e\u003e\u003e\u003e--------+\n        |              |                    |            |\n        |              |                    |            |\n        |              +--------------------+            |\n+-----------------+                            +-------------------+\n|                 |                            |                   |\n|    Client       |                            |     Worker        |\n|    pushes       |                            |     pulls         |\n|     jobs        |                            |      jobs         |\n|                 |                            |                   |\n|                 |                            |                   |\n+-----------------+                            +-------------------+\n```\n\n- Client - an API any process can use to push jobs to the Faktory server.\n- Worker - a process that pulls jobs from Faktory and executes them.\n- Server - the Faktory daemon which stores background jobs in queues to be\n  processed by Workers.\n\nThis package contains only the client and worker parts. The server part is\n[here](https://github.com/contribsys/faktory/)\n\n## Installation\n\n- Hackage: http://hackage.haskell.org/package/faktory\n- Stackage: *Coming soon*\n\n## Faktory Documentation\n\nSee the [wiki](//github.com/contribsys/faktory/wiki) for more\ndetails.\n\n## Usage\n\n\u003c!--\n```haskell\nimport Data.Aeson\nimport Prelude\nimport Faktory.Producer\nimport Faktory.Job\nimport Faktory.Worker\nimport GHC.Generics\nimport Text.Markdown.Unlit ()\n\n{- Don't actually run anything -}\nmain :: IO ()\nmain = if True then pure () else (workerMain \u003e\u003e producerMain)\nworkerMain :: IO ()\nproducerMain :: IO ()\n```\n--\u003e\n\n### Job\n\nAny value can be a \"Job\" that is pushed and pulled to and from Faktory via its\n`ToJSON` and `FromJSON` instances:\n\n```haskell\nnewtype MyJob = MyJob\n  { myJobMessage :: String\n  }\n  deriving stock Generic\n  deriving anyclass (ToJSON, FromJSON)\n```\n\n### Worker\n\n```haskell\nworkerMain = runWorkerEnv $ \\job -\u003e do\n  -- Process your Job here\n  putStrLn $ jobJid job\n  putStrLn $ myJobMessage $ jobArg job\n\n  -- If any exception is thrown, the job will be marked as Failed in Faktory\n  -- and retried. Note: you will not otherwise hear about any such exceptions,\n  -- unless you catch-and-rethrow them yourself.\n```\n\n### Producer\n\n`Producer` wraps `Client` for push-only usage.\n\n```haskell\nproducerMain = do\n  producer \u003c- newProducerEnv\n\n  jobId \u003c- perform mempty producer $ MyJob \"Hello world\"\n\n  print jobId\n\n  closeProducer producer\n```\n\n### Configuration\n\nWhen using `envSettings`, the following variables will be used:\n\n- `FAKTORY_PROVIDER`: the name of another environment variable where the\n  connection string can be found. Defaults to `FAKTORY_URL`.\n- `FAKTORY_URL` (or whatever you named in `FAKTORY_PROVIDER`): connection string\n  to the Faktory server. Format is\n  `tcp(+tls)://(:password@)host:port(/namespace)`. Defaults to\n  `tcp://localhost:4719`. `namespace` is prependend to queue names on job\n  submission and worker consumption.\n\nWhen using `envWorkerSettings`, the following variables are also used:\n\n- `FAKTORY_QUEUE`: the name of the queue to consume from. Default is \"default\".\n- `FAKTORY_WORKER_ID`: the Id to use for this Worker. Default is to assign a\n  random one.\n\n## Examples\n\nSee the [examples](./examples). To run them:\n\n1. Run a local Faktory server\n\n   ```console\n   docker run --rm \\\n     --publish 7419:7419 \\\n     --publish 7420:7420 \\\n     contribsys/faktory\n   ```\n\n1. Run the consumer example\n\n   ```console\n   % stack exec faktory-example-consumer\n   Starting consumer loop\n   ```\n\n   (Assumes you've built the project.)\n\n1. Submit a Job through the producer example\n\n   ```console\n   % stack exec faktory-example-producer hello world\n   Pushed job: \"ljcjlbexbgun\"\n   ```\n\n   *NOTE*: if you submit \"BOOM\" as a Job, the processing loop will raise an\n   exception, so you can see how a Failed Job looks in Faktory.\n\n1. See that your Job was processed back in the consumer\n\n   ```console\n   % stack exec faktory-example-consumer\n   Starting consumer loop\n   hello world\n   ```\n\n## Development \u0026 Tests\n\n```console\nstack build --dependencies-only --test --no-run-tests\nstack build --pedantic --test --no-run-tests\nstack build --pedantic --test\n```\n\n- `FactorySpec` requires a local Faktory server is running, and it will flush\n  all Jobs from this server as part of running the tests.\n- The tests for `BATCH` require testing against an Enterprise Faktory image\n\n---\n\n[CHANGELOG](./CHANGELOG.md) | [LICENSE](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreckle%2Ffaktory_worker_haskell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreckle%2Ffaktory_worker_haskell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreckle%2Ffaktory_worker_haskell/lists"}