{"id":28643106,"url":"https://github.com/cometsh/drinkup","last_synced_at":"2025-06-18T09:04:16.446Z","repository":{"id":296549173,"uuid":"993793458","full_name":"cometsh/drinkup","owner":"cometsh","description":"Elixir ATProtocol firehose \u0026 subscription listener","archived":false,"fork":false,"pushed_at":"2025-06-07T12:31:22.000Z","size":25,"stargazers_count":9,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-12T23:03:01.120Z","etag":null,"topics":["atproto","atproto-sync","atprotocol","elixir","sync","websockets"],"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/cometsh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2025-05-31T14:36:20.000Z","updated_at":"2025-06-07T12:31:26.000Z","dependencies_parsed_at":"2025-06-01T01:44:16.225Z","dependency_job_id":"3af6a63b-2ee7-490b-898e-638ce429e358","html_url":"https://github.com/cometsh/drinkup","commit_stats":null,"previous_names":["cometsh/drinkup"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cometsh/drinkup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cometsh%2Fdrinkup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cometsh%2Fdrinkup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cometsh%2Fdrinkup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cometsh%2Fdrinkup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cometsh","download_url":"https://codeload.github.com/cometsh/drinkup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cometsh%2Fdrinkup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260523584,"owners_count":23021968,"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":["atproto","atproto-sync","atprotocol","elixir","sync","websockets"],"created_at":"2025-06-12T23:01:43.492Z","updated_at":"2025-06-18T09:04:16.391Z","avatar_url":"https://github.com/cometsh.png","language":"Elixir","funding_links":[],"categories":["Elixir"],"sub_categories":[],"readme":"# Drinkup\n\nAn Elixir library for listening to events from an ATProtocol relay\n(firehose/`com.atproto.sync.subscribeRepos`). Eventually aiming to support any\nATProtocol subscription.\n\n## TODO\n\n- Support for different subscriptions other than\n  `com.atproto.sync.subscribeRepo'.\n- Validation (signatures, making sure to only track handle active accounts,\n  etc.) (see\n  [Firehose Validation Best Practices](https://atproto.com/specs/sync#firehose-validation-best-practices))\n- Look into backfilling? See if there's better ways to do it.\n- Built-in solutions for tracking resumption? (probably a pluggable solution to\n  allow for different things like Mnesia, Postgres, etc.)\n- Testing of multi-node/distribution.\n- Tests\n- Documentation\n\n## Installation\n\nAdd `drinkup` to your `mix.exs`.\n\n```elixir\ndef deps do\n  [\n    {:drinkup, \"~\u003e 0.1\"}\n  ]\nend\n```\n\nDocumentation can be found on HexDocs at https://hexdocs.pm/drinkup.\n\n## Example Usage\n\nFirst, create a module implementing the `Drinkup.Consumer` behaviour (only\nrequires a `handle_event/1` function):\n\n```elixir\ndefmodule ExampleConsumer do\n  @behaviour Drinkup.Consumer\n\n  def handle_event(%Drinkup.Event.Commit{} = event) do\n    IO.inspect(event, label: \"Got commit event\")\n  end\n\n  def handle_event(_), do: :noop\nend\n```\n\nThen add Drinkup and your consumer to your application's supervision tree:\n\n```elixir\ndefmodule MyApp.Application do\n  use Application\n\n  def start(_type, _args) do\n    children = [{Drinkup, %{consumer: ExampleConsumer}}]\n    Supervisor.start_link(children, strategy: :one_for_one)\n  end\nend\n```\n\nYou should then be able to start your application and start seeing\n`Got commit event: ...` in the terminal.\n\n### Record Consumer\n\nOne of the main reasons for listening to an ATProto relay is to synchronise a\ndatabase with records. As a result, Drinkup provides a light extension around a\nbasic consumer, the `RecordConsumer`, which only listens to commit events, and\ntransforms them into a slightly nicer structure to work around, calling your\n`handle_create/1`, `handle_update/1`, and `handle_delete/1` functions for each\nrecord it comes across. It also allows for filtering of specific types of\nrecords either by full name or with a\n[Regex](https://hexdocs.pm/elixir/1.18.4/Regex.html) match.\n\n```elixir\ndefmodule ExampleRecordConsumer do\n  # Will respond to any events either `app.bsky.feed.post` records, or anything under `app.bsky.graph`.\n  use Drinkup.RecordConsumer, collections: [~r/app\\.bsky\\.graph\\..+/, \"app.bsky.feed.post\"]\n  alias Drinkup.RecordConsumer.Record\n\n  def handle_create(%Record{type: \"app.bsky.feed.post\"} = record) do\n    IO.inspect(record, label: \"Bluesky post created\")\n  end\n\n  def handle_create(%Record{type: \"app.bsky.graph\" \u003c\u003e _} = record) do\n    IO.inspect(record, label: \"Bluesky graph updated\")\n  end\n\n  def handle_update(record) do\n    # ...\n  end\n\n  def handle_delete(record) do\n    # ...\n  end\nend\n```\n\n## Special thanks\n\nThe process structure used in Drinkup is heavily inspired by the work done on\n[Nostrum](https://github.com/Kraigie/nostrum), an incredible Elixir library for\nDiscord.\n\n## License\n\nThis project is licensed under the [MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcometsh%2Fdrinkup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcometsh%2Fdrinkup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcometsh%2Fdrinkup/lists"}