{"id":14446733,"url":"https://github.com/ezcater/activerecord-postgres_pub_sub","last_synced_at":"2025-04-13T00:48:16.226Z","repository":{"id":32698674,"uuid":"120470913","full_name":"ezcater/activerecord-postgres_pub_sub","owner":"ezcater","description":"Support for PostgreSQL LISTEN and NOTIFY","archived":false,"fork":false,"pushed_at":"2025-02-04T18:42:10.000Z","size":76,"stargazers_count":58,"open_issues_count":2,"forks_count":10,"subscribers_count":71,"default_branch":"main","last_synced_at":"2025-04-13T00:48:11.595Z","etag":null,"topics":["library","postgres","postgresql","pub-sub","rubygem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/ezcater.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-02-06T14:35:18.000Z","updated_at":"2025-02-15T07:38:38.000Z","dependencies_parsed_at":"2024-09-01T07:02:14.450Z","dependency_job_id":"28b5f915-d86c-415e-88d7-d5a01bb0359c","html_url":"https://github.com/ezcater/activerecord-postgres_pub_sub","commit_stats":{"total_commits":55,"total_committers":9,"mean_commits":6.111111111111111,"dds":0.6545454545454545,"last_synced_commit":"e98ea7c9e9ffac45ee53f52d4093aa17274a0f9a"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezcater%2Factiverecord-postgres_pub_sub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezcater%2Factiverecord-postgres_pub_sub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezcater%2Factiverecord-postgres_pub_sub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezcater%2Factiverecord-postgres_pub_sub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezcater","download_url":"https://codeload.github.com/ezcater/activerecord-postgres_pub_sub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650437,"owners_count":21139672,"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":["library","postgres","postgresql","pub-sub","rubygem"],"created_at":"2024-09-01T07:01:05.439Z","updated_at":"2025-04-13T00:48:16.192Z","avatar_url":"https://github.com/ezcater.png","language":"Ruby","readme":"# activerecord-postgres_pub_sub\n\nThis gem contains support for PostgreSQL LISTEN and NOTIFY functionality:\n[doc](https://www.postgresql.org/docs/9.6/static/libpq-notify.html).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"activerecord-postgres_pub_sub\"\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install activerecord-postgres_pub_sub\n\n## Usage\n\n### Listener\n\nThe `Listener` class is used to handle notification messages on one or more\nchannels.\n\nThe listener can be configured with three blocks:\n\n* **on_notify**: called whenever a notification is received.\n* **on_start**: called before receiving any notifications.\n* **on_timeout**: called based on a configurable timeout, when no notifications\n  have been received.\n\nWhen creating a listener, the following configuration is supported:\n\n* **listen_timeout**: If set, the `on_timeout` block will be called if\n  no notifications are received within this period. (Default `nil`).\n* **notify_only**: A payload string can be included in notifications. By default\n  the listener ignores the payload and coalesces multiple notifications into a\n  single call. When this option is `false`, the `on_notify` block is called with\n  the payload for each notification. (Default `true`).\n* **base_class**: An Active Record class should you need to use a different base\n  class (e.g. for multiple database support). (Default `ActiveRecord::Base`).\n* **exclusive_lock**: Acquire a lock using\n  [with_advisory_lock](https://github.com/ClosureTree/with_advisory_lock) prior to listening.\n  This option ensures that a process as a singleton listener. (Default `true`).\n\nExample:\n\n```ruby\nActiveRecord::PostgresPubSub::Listener.listen(\"notify_channel\", listen_timeout: 30) do |listener|\n  listener.on_start do\n    # when starting assume we missed something and perform regular activity\n    handle_notification\n  end\n\n  listener.on_notify do\n    handle_notification\n  end\n\n  listener.on_timeout do\n    perform_regular_maintenance\n  end\nend\n```\n\n### Generator\n\nThis gem contains a Rails generator for a migration to add a trigger to notify on insert to a table.\n\nThe generator must be run with a model name corresponding to the table.\n\n```bash\nrails generate active_record:postgres_pub_sub:notify_on_insert --model_name NameSpace::Entity\n```\n\nIn this example, notification events would be generated for the channel named `\"name_space_entity\"` based\non inserts to the `name_space_entities` table.\n\n## Supported dependencies\n\nThis gem will not support versions of ruby and activerecord which no\nlonger receive security updates. It will support the latest major\nversion of the pg gem and it will be tested against the latest minor /\npatch version of that gem.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then,\nrun `rake spec` to run the tests. You can also run `bin/console` for an\ninteractive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\nTo release a new version, update the version number in `version.rb`, and then\nrun `bundle exec rake release`, which will create a git tag for the version,\npush git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/ezcater/activerecord-postgres_pub_sub.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezcater%2Factiverecord-postgres_pub_sub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezcater%2Factiverecord-postgres_pub_sub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezcater%2Factiverecord-postgres_pub_sub/lists"}