{"id":28412227,"url":"https://github.com/electric-sql/pg_protocol","last_synced_at":"2026-07-03T19:33:54.247Z","repository":{"id":187489902,"uuid":"676999036","full_name":"electric-sql/pg_protocol","owner":"electric-sql","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-03T13:47:32.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-29T08:51:29.407Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/electric-sql.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}},"created_at":"2023-08-10T13:56:22.000Z","updated_at":"2024-11-18T12:55:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"67055ee8-ff67-43d8-be79-604699111bee","html_url":"https://github.com/electric-sql/pg_protocol","commit_stats":null,"previous_names":["electric-sql/pg_protocol"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/electric-sql/pg_protocol","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electric-sql%2Fpg_protocol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electric-sql%2Fpg_protocol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electric-sql%2Fpg_protocol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electric-sql%2Fpg_protocol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/electric-sql","download_url":"https://codeload.github.com/electric-sql/pg_protocol/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electric-sql%2Fpg_protocol/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35099547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-06-02T20:15:30.592Z","updated_at":"2026-07-03T19:33:54.242Z","avatar_url":"https://github.com/electric-sql.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://electric-sql.com\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\"\n        srcset=\"https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-light-trans.svg\"\n    /\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\"\n        srcset=\"https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-black.svg\"\n    /\u003e\n    \u003cimg alt=\"ElectricSQL logo\"\n        src=\"https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-black.svg\"\n    /\u003e\n  \u003c/picture\u003e\n\u003c/a\u003e\n\n[![License - Apache 2.0](https://img.shields.io/badge/license-Apache_2.0-blue)](main/LICENSE)\n\n# PgProtocol\n\nAn [Elixir](https://elixir-lang.org) library to handle the encoding and decoding of [Postgresql frontend/backend protocol](https://www.postgresql.org/docs/current/protocol.html) messages.\n\n```elixir\n# decode messages streaming from a Postgresql server over TCP\n# and broadcast to GenStage consumers\ndefmodule PostgresConnectionProducer do\n  use GenStage\n\n  @impl GenStage\n  def init(args) do\n    # establish a TCP connection to the Postgresql server\n    # we're ignoring any connection setup and authentication\n    {:ok, conn} = :gen_tcp.connect(to_charlist(host), 5432, [active: true])\n\n    # if we're receiving messages from a client, e.g. psql, then\n    # use `PgProtocol.Decoder.frontend()`\n    decoder = PgProtocol.Decoder.backend()\n\n    {:producer, {conn, decoder}}\n  end\n\n  @impl GenStage\n  def handle_info({:tcp, _conn, data}, {conn, decoder}) do\n    {:ok, decoder, msgs} = PgProtocol.decode(decoder, data)\n    {:noreply, msgs, {conn, decoder}}\n  end\nend\n```\n\n## Status\n\nThis library is used internally by [electric](https://github.com/electric-sql/electric) to de- and encode messages as part of a postgresql proxy implementation.\n\nAs such it is very much a work in progress, having only the functionality required by that project.\n\nThere are currently a few message types, `PasswordMessage`, `SASLInitialResponse` and `GSSResponse` that share a tag and are impossible to decode without some authentication flow context.\n\nWe currently only support the `GSSResponse` type and don't have any kind of context for differentiating between these messages.\n\n## Installation\n\n**This package is not currently published to Hex**\n\nThis package can be installed by adding `pg_protocol` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:pg_protocol, github: \"electric-sql/pg_protocol\"}\n  ]\nend\n```\n\n## License\n\nThis Elixir library is distributed under the terms of the [Apache 2.0 license](LICENSE).\n\n## Contributing\n\nSee the [Community Guidelines](https://github.com/electric-sql/meta) including the [Guide to Contributing](https://github.com/electric-sql/meta/blob/main/CONTRIBUTING.md) and [Contributor License Agreement](https://github.com/electric-sql/meta/blob/main/CLA.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectric-sql%2Fpg_protocol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felectric-sql%2Fpg_protocol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectric-sql%2Fpg_protocol/lists"}