{"id":15355692,"url":"https://github.com/doomspork/transfusion","last_synced_at":"2025-04-09T08:41:34.794Z","repository":{"id":72817168,"uuid":"95230346","full_name":"doomspork/transfusion","owner":"doomspork","description":"An experimental event-based work flow","archived":false,"fork":false,"pushed_at":"2017-10-10T18:23:59.000Z","size":28,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-15T02:44:12.915Z","etag":null,"topics":["elixir-lang","experimental","message-passing"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/doomspork.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":"2017-06-23T15:00:27.000Z","updated_at":"2021-01-19T05:39:26.000Z","dependencies_parsed_at":"2023-09-18T06:30:51.715Z","dependency_job_id":null,"html_url":"https://github.com/doomspork/transfusion","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"2c144a1cf5e93750358f8d307b4d9ad3d81b9b82"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doomspork%2Ftransfusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doomspork%2Ftransfusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doomspork%2Ftransfusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doomspork%2Ftransfusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doomspork","download_url":"https://codeload.github.com/doomspork/transfusion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008025,"owners_count":21032545,"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":["elixir-lang","experimental","message-passing"],"created_at":"2024-10-01T12:25:13.682Z","updated_at":"2025-04-09T08:41:34.777Z","avatar_url":"https://github.com/doomspork.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Transfusion [![Build Status][travis-img]][travis] [![License][license-img]][license]\n\n[travis-img]: https://travis-ci.org/doomspork/transfusion.svg?branch=master\n[travis]: https://travis-ci.org/doomspork/transfusion\n[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg\n[license]: http://opensource.org/licenses/MIT\n\nAn experimental event-based work flow — you probably don't want to use it just yet.\n\n## Installation\n\nThe package is currently not on hex, instead point to master:\n\n```elixir\ndef deps do\n  [{:transfusion, github: \"doomspork/transfusion\"}]\nend\n```\n\n## Routing Messages\n\nThe router is the core of `Transfusion` handling the message routing and results.  The router also maintains a list of current messages, retrying expired messages with an exponential backoff.\n\n```elixir\ndefmodule Example.Router do\n  use Transfusion.Router,\n    max_retries: 5,\n    retry_after: 10000 # milliseconds\n\n  require Logger\n\n  broadcast \"*\", to: [AnotherExample.Router]\n\n  forward \"users\", to: Users.Router\n\n  topic \"events\", Example.Consumer do\n    map \"new.message\", to: :new\n  end\n\n  def handle_error(msg, reason) do\n    # Log or submit your error\n\n    :noretry\n  end\nend\n```\n\nThe `broadcast/2` macro enables us to distributes messages to other router throughout our application in addition to processing it ourselves.\n\nWe can redirect, or forward, all messages for a given topic to another router using `forward/2`.\n\nMost importantly is the `topic/2` and `map/2` macros, with these we can subscribe a consumer to various messages on a given topic.\n\n## Message Producing\n\nMessages are primarily syntactic sugar for creating structs with a splash of validation.  You can use `Transfusion` without creating a message module, maps work just fine!\n\n```elixir\ndefmodule Example.Message do\n  use Transfusion.Message,\n    router: Example.Router\n\n  topic \"events\"\n\n  message_type \"new.message\"\n\n  values do\n    attribute :subject, String\n    attribute :body, String, required: true\n  end\nend\n```\n\n## Message Consuming\n\nConsumers do the real work in `Transfusion`.  A consumer received events and is expected to do some work, returning `{:ok, result}` or `{:error, reason}`.\n\n```elixir\ndefmodule Example.Consumer do\n  require Logger\n\n  def new(%{body: body, _meta: %{id: id}}),\n    do: Logger.info(\"Message (id: #{id}) received with body: #{body}\")\nend\n```\n\n## Contributing\n\nFeedback, feature requests, and fixes are welcomed and encouraged.  Please\nmake appropriate use of [Issues][issues] and [Pull Requests][pulls].  All code\nshould have accompanying tests.\n\n[issues]: https://github.com/doomspork/transfusion/issues\n[pulls]: https://github.com/doomspork/transfusion/pulls\n\n\n## License\n\nMIT license. Please see [LICENSE][license] for details.\n\n[LICENSE]: https://github.com/doomspork/transfusion/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoomspork%2Ftransfusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoomspork%2Ftransfusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoomspork%2Ftransfusion/lists"}