{"id":13508759,"url":"https://github.com/bitgamma/boltun","last_synced_at":"2025-04-07T11:10:45.445Z","repository":{"id":25943252,"uuid":"29384756","full_name":"bitgamma/boltun","owner":"bitgamma","description":"Transforms notifications from the Postgres LISTEN/NOTIFY mechanism into callback execution","archived":false,"fork":false,"pushed_at":"2018-07-03T03:06:04.000Z","size":18,"stargazers_count":135,"open_issues_count":2,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T10:06:14.663Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitgamma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-17T08:10:12.000Z","updated_at":"2024-07-23T03:42:03.000Z","dependencies_parsed_at":"2022-08-24T14:17:56.396Z","dependency_job_id":null,"html_url":"https://github.com/bitgamma/boltun","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitgamma%2Fboltun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitgamma%2Fboltun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitgamma%2Fboltun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitgamma%2Fboltun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitgamma","download_url":"https://codeload.github.com/bitgamma/boltun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640465,"owners_count":20971557,"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":[],"created_at":"2024-08-01T02:00:58.034Z","updated_at":"2025-04-07T11:10:45.409Z","avatar_url":"https://github.com/bitgamma.png","language":"Elixir","funding_links":[],"categories":["ORM and Datamapping"],"sub_categories":[],"readme":"# Boltun\n\n[![Build Status](https://travis-ci.org/bitgamma/boltun.svg?branch=master)](https://travis-ci.org/bitgamma/boltun)\n\nBoltun simplifies handling of the LISTEN/NOTIFY mechanism offered by Postgres. Basically you will just need to define which callback(s) should be called on a specific notification and that's it\n\n## Usage\n\nAdd Boltun as a dependency in your `mix.exs` file.\n\n```elixir\ndefp deps do\n  [{:boltun, \"~\u003e 1.0.2\"}]\nend\n```\n\nAfter you are done, run `mix deps.get` in your shell to fetch the dependencies.\n\n## Defining a listener\n\nDefining a listener is trivial. See the example below\n\n```elixir\ndefmodule TestListener do\n  use Boltun, otp_app: :my_app\n\n  listen do\n    channel \"my_channel\", :my_callback\n    channel \"my_channel\", :my_other_callback\n    channel \"my_other_channel\", :my_other_callback\n  end\n\n  def my_callback(channel, payload) do\n    IO.puts channel\n    IO.puts payload\n  end\n  ...\nend\n```\n\nThe channel is a concept defined by Postgres. On the SQL side you will have something like `NOTIFY my_channel, 'my payload'` happening, for example, in a trigger which will cause your callbacks TestListener.my_callback and TestListener.my_other_callback to be called. The callbacks will be invoked synchronously in the order they were declared in the listen block.\n\n## Using a listener\n\nDefining a listener is not enough to use it. It should be started with `TestListener.start_link`. You can do this, for example, in a supervisor.\nThe listener also needs the connection parameters to establish a connection. You will provide this in your config.exs file in this format\n\n```elixir\n  ...\n  config :my_app, TestListener, database: \"postgres\", username: \"postgres\", password: \"postgres\", hostname: \"localhost\"\n  ...\n```\n\nThe full list of options can be read in the documentation for Postgrex.\n\n## License\nCopyright (c) 2014, Bitgamma OÜ \u003cmichele@briksoftware.com\u003e\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitgamma%2Fboltun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitgamma%2Fboltun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitgamma%2Fboltun/lists"}