{"id":20611949,"url":"https://github.com/craigpastro/pgmq-go","last_synced_at":"2025-06-19T16:40:45.355Z","repository":{"id":187095434,"uuid":"676215743","full_name":"craigpastro/pgmq-go","owner":"craigpastro","description":"A Go (Golang) client for Postgres Message Queue (PGMQ)","archived":false,"fork":false,"pushed_at":"2025-05-02T00:52:30.000Z","size":114,"stargazers_count":57,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-20T09:07:48.185Z","etag":null,"topics":["go","golang","postgres","postgres-extension","postgresql","queue"],"latest_commit_sha":null,"homepage":"","language":"Go","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/craigpastro.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":"2023-08-08T17:31:57.000Z","updated_at":"2025-05-18T23:03:05.000Z","dependencies_parsed_at":"2024-05-11T06:21:27.935Z","dependency_job_id":"8a400c65-eb3b-41be-aa9c-7a551c52899c","html_url":"https://github.com/craigpastro/pgmq-go","commit_stats":null,"previous_names":["craigpastro/pgmq-go"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/craigpastro/pgmq-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigpastro%2Fpgmq-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigpastro%2Fpgmq-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigpastro%2Fpgmq-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigpastro%2Fpgmq-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craigpastro","download_url":"https://codeload.github.com/craigpastro/pgmq-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craigpastro%2Fpgmq-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260789709,"owners_count":23063617,"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":["go","golang","postgres","postgres-extension","postgresql","queue"],"created_at":"2024-11-16T10:22:43.977Z","updated_at":"2025-06-19T16:40:40.338Z","avatar_url":"https://github.com/craigpastro.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgmq-go\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/craigpastro/pgmq-go.svg)](https://pkg.go.dev/github.com/craigpastro/pgmq-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/craigpastro/pgmq-go)](https://goreportcard.com/report/github.com/craigpastro/pgmq-go)\n[![CI](https://github.com/craigpastro/pgmq-go/actions/workflows/push_to_main.yaml/badge.svg)](https://github.com/craigpastro/pgmq-go/actions/workflows/push_to_main.yaml)\n[![codecov](https://codecov.io/github/craigpastro/pgmq-go/branch/main/graph/badge.svg?token=00AJODX77Z)](https://codecov.io/github/craigpastro/pgmq-go)\n\nA Go (Golang) client for\n[Postgres Message Queue](https://github.com/tembo-io/pgmq) (PGMQ). Based loosely\non the [Rust client](https://github.com/tembo-io/pgmq/tree/main/pgmq-rs).\n\n`pgmq-go` works with [pgx](https://github.com/jackc/pgx). The second argument of most functions only needs to satisfy the [DB](https://pkg.go.dev/github.com/craigpastro/pgmq-go#DB) interface, which means it can take, among others, a `*pgx.Conn`, `*pgxpool.Pool`, or `pgx.Tx`.\n\n## Usage\n\nStart a Postgres instance with the PGMQ extension installed:\n\n```shell\ndocker run -d --name postgres -e POSTGRES_PASSWORD=password -p 5432:5432 quay.io/tembo/pgmq-pg:latest\n```\n\nThen\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n\n    \"github.com/craigpastro/pgmq-go\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    pool, err := pgmq.NewPgxPool(ctx, \"postgres://postgres:password@localhost:5432/postgres\")\n    if err != nil {\n        panic(err)\n    }\n\n    err = pgmq.CreatePGMQExtension(ctx, pool)\n    if err != nil {\n        panic(err)\n    }\n\n    err = pgmq.CreateQueue(ctx, pool, \"my_queue\")\n    if err != nil {\n        panic(err)\n    }\n\n    // We can perform various queue operations using a transaction.\n    tx, err := pool.Begin(ctx)\n    if err != nil {\n        panic(err)\n    }\n\n    id, err := pgmq.Send(ctx, tx, \"my_queue\", json.RawMessage(`{\"foo\": \"bar\"}`))\n    if err != nil {\n        panic(err)\n    }\n\n    msg, err := pgmq.Read(ctx, tx, \"my_queue\", 30)\n    if err != nil {\n        panic(err)\n    }\n\n    // Archive the message by moving it to the \"pgmq.a_\u003cqueue_name\u003e\" table.\n    // Alternatively, you can `Delete` the message, or read and delete in one\n    // call by using `Pop`.\n    _, err = pgmq.Archive(ctx, tx, \"my_queue\", id)\n    if err != nil {\n        panic(err)\n    }\n\n    // Commit the transaction.\n    err = tx.Commit(ctx)\n    if err != nil {\n        panic(err)\n    }\n\n    // Close the connection pool.\n    pool.Close()\n}\n```\n\n## Contributions\n\nWe :heart: contributions.\n\n## See also\n\n- [joeychilson/pgmq](https://github.com/joeychilson/pgmq)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraigpastro%2Fpgmq-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraigpastro%2Fpgmq-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraigpastro%2Fpgmq-go/lists"}