{"id":18002835,"url":"https://github.com/am-kantox/envio","last_synced_at":"2025-05-12T14:30:17.377Z","repository":{"id":32772541,"uuid":"142136950","full_name":"am-kantox/envio","owner":"am-kantox","description":"Application-wide registry with handy helpers to ease dispatching","archived":false,"fork":false,"pushed_at":"2025-05-10T08:04:26.000Z","size":183,"stargazers_count":19,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-10T09:19:29.281Z","etag":null,"topics":["elixir","elixir-lang","messaging","registry"],"latest_commit_sha":null,"homepage":null,"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/am-kantox.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":"2018-07-24T09:34:38.000Z","updated_at":"2024-06-18T06:10:42.000Z","dependencies_parsed_at":"2024-05-23T00:37:52.171Z","dependency_job_id":"95e6617d-910b-4ce4-b873-c7be9d9fcf7e","html_url":"https://github.com/am-kantox/envio","commit_stats":{"total_commits":87,"total_committers":3,"mean_commits":29.0,"dds":0.06896551724137934,"last_synced_commit":"2e6dc19b929ce3d4e7bece98291a48ec44adcb51"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Fenvio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Fenvio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Fenvio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Fenvio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/am-kantox","download_url":"https://codeload.github.com/am-kantox/envio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253392415,"owners_count":21901082,"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","elixir-lang","messaging","registry"],"created_at":"2024-10-29T23:24:11.119Z","updated_at":"2025-05-12T14:30:17.317Z","avatar_url":"https://github.com/am-kantox.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![Logo](/stuff/logo-48x48.png?raw=true) Envío    [![Kantox ❤ OSS](https://img.shields.io/badge/❤-kantox_oss-informational.svg)](https://kantox.com/)  ![Test](https://github.com/am-kantox/envio/workflows/Test/badge.svg)  ![Dialyzer](https://github.com/am-kantox/envio/workflows/Dialyzer/badge.svg)\n\n**Application-wide registry with handy helpers to ease dispatching.**\n\n## Installation\n\nSimply add `envio` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:envio, \"~\u003e 1.0\"}\n  ]\nend\n```\n\n## Usage\n\n### Simple publisher\n\nUse `Envio.Publisher` helper to scaffold the registry publisher. It provides\n`broadcast/2` helper (and `brodcast/1` if the default channel is set.)\n\n```elixir\ndefmodule Spitter.Registry do\n  use Envio.Publisher, channel: :main\n\n  def spit(channel, what), do: broadcast(channel, what)\n  def spit(what), do: broadcast(what)\nend\n```\n\n### Simple subscriber ([`dispatch`](https://hexdocs.pm/elixir/master/Registry.html#module-using-as-a-dispatcher))\n\nJust register your handler anywhere in the code:\n\n```elixir\nEnvio.register(\n  {Sucker, :suck},\n  dispatch: %Envio.Channel{source: Spitter.Registry, name: :foo}\n)\n```\n\n`Sucker.suck/1` will be called with a payload.\n\n### PubSub subscriber ([`pub_sub`](https://hexdocs.pm/elixir/master/Registry.html#module-using-as-a-pubsub))\n\nUse `Envio.Subscriber` helper to scaffold the registry subscriber. Implement\n`handle_envio/2` for custom message handling. The default implementation\ncollects last 10 messages in it’s state.\n\n```elixir\ndefmodule PubSucker do\n  use Envio.Subscriber, channels: [{Spitter.Registry, :foo}]\n\n  def handle_envio(message, state) do\n    {:noreply, state} = super(message, state)\n    IO.inspect({message, state}, label: \"PubSucked\")\n    {:noreply, state}\n  end\nend\n```\n\n### Phoenix.PubSub subscriber ([`phoenix_pub_sub`](https://hexdocs.pm/phoenix_pubsub))\n\nUse `manager: :phoenix_pub_sub` for distributed message broadcasting. The implementation below subscribes to `\"main\"` channel in the distributed OTP environment and prints out each subsequent incoming message to standard output.\n\n```elixir\ndefmodule Pg2Sucker do\n  use Envio.Subscriber, channels: [\"main\"], manager: :phoenix_pub_sub\n\n  def handle_envio(message, state) do\n    {:noreply, state} = super(message, state)\n    IO.inspect({message, state}, label: \"Received\")\n    {:noreply, state}\n  end\nend\n```\n\nThe publisher this subscriber might be listening to would look like\n\n```elixir\ndefmodule Pg2Spitter do\n  use Envio.Publisher, manager: :phoenix_pub_sub, channel: \"main\"\n  def spit(channel, what), do: broadcast(channel, what)\n  def spit(what), do: broadcast(what)\nend\n```\n\n## Changelog\n\n- **`1.0.0`** → Modern Elixir v1.16 update, no more features planned\n- **`0.10.2`** → Accept `:warning` alongside `:warn`\n- **`0.10.1`** → Runtime configs for backends via `{:system, value}` tuples\n- **`0.10.0`** → `Process` backend\n- **`0.8.0`** → `Phoenix.PubSub` support (+ backend)\n- **`0.5.0`** → removed a dependency from `Slack` package\n- **`0.4.0`** → better docs and other enhancements\n- **`0.3.0`** → `Envio.Backend` and infrastructure for backends; `Slack` as an example.\n\n## ToDo\n\n- Back pressure with [`GenStage`](https://hexdocs.pm/gen_stage/GenStage.html)\n  for `:dispatch` kind of delivery;\n- Set of backends for easy delivery (_slack_, _redis_, _rabbit_, etc.)\n\n## [Documentation](https://hexdocs.pm/envio)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fam-kantox%2Fenvio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fam-kantox%2Fenvio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fam-kantox%2Fenvio/lists"}