Skip to content

Commit

Permalink
Add PGXN release workflow
Browse files Browse the repository at this point in the history
PGXN requires a `META.json` file, so add it and a `make` target to fill
in the version from `Cargo.toml`. Add `.gitattributes` to prevent `git
archive` from archiving some files (should more be omitted from the
release? What about the `.cargo` directory?) and
`.github/workflows/pgxn-release.yml` to do the actual release when a tag
is pushed.

Also tweak the `README` a bit to address some inconsistencies.
  • Loading branch information
theory committed Jan 11, 2024
1 parent 2e6159b commit 3e662a0
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gitignore export-ignore
.gitattributes export-ignore
.github export-ignore
*.bak export-ignore
21 changes: 21 additions & 0 deletions .github/workflows/pgxn-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: ⚙️ Release on PGXN
on:
push:
tags: [v*]
branches: [pgxn]
jobs:
release:
name: Release on PGXN
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Bundle the Release
run: make META.json.bak && pgxn-bundle
- name: Release on PGXN
env:
PGXN_USERNAME: ${{ secrets.PGXN_USERNAME }}
PGXN_PASSWORD: ${{ secrets.PGXN_PASSWORD }}
# run: pgxn-release
run: ls -lah
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ docker/**
*.deb
poetry.lock
site
*.bak
49 changes: 49 additions & 0 deletions META.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "pgmq",
"abstract": "A lightweight message queue like AWS SQS or RSMQ, but on Postgres",
"description": "A lightweight message queue for PostgreSQL, like AWS SQS or RSMQ, but entirely in the database.",
"version": "@CARGO_VERSION@",
"maintainer": [
"Tembo <[email protected]>"
],
"license": "postgresql",
"provides": {
"pgmq": {
"abstract": "A lightweight message queue like AWS SQS or RSMQ, but on Postgres",
"file": "src/sql_src.sql",
"docfile": "README.md",
"version": "@CARGO_VERSION@"
}
},
"prereqs": {
"runtime": {
"requires": {
"PostgreSQL": "11.0.0"
},
"recommends": {
"pg_partman": "4.5.1"
}
}
},
"resources": {
"bugtracker": {
"web": "https://github.com/tembo-io/pgmq/issues/"
},
"repository": {
"url": "git://github.com/tembo-io/pgmq.git",
"web": "https://github.com/tembo-io/pgmq/",
"type": "git"
}
},
"generated_by": "David E. Wheeler",
"meta-spec": {
"version": "1.0.0",
"url": "https://pgxn.org/meta/spec.txt"
},
"tags": [
"mq",
"message queue",
"sqs",
"rsmq"
]
}
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PGRX_POSTGRES ?= pg15
DISTVERSION = $(shell grep -m 1 '^version' Cargo.toml | sed -e 's/[^"]*"\([^"]*\)",\{0,1\}/\1/')

test:
cargo pgrx test $(PGRX_POSTGRES)
Expand All @@ -10,3 +11,10 @@ format:

run.postgres:
docker run -d --name pgmq-pg -e POSTGRES_PASSWORD=postgres -p 5432:5432 quay.io/tembo/pgmq-pg:latest

META.json.bak: Cargo.toml META.json
@sed -i.bak "s/@CARGO_VERSION@/$(DISTVERSION)/g" META.json

pgxn-zip: META.json.bak
git archive --format zip --prefix=pgmq-$(DISTVERSION)/ -o pgmq-$(DISTVERSION).zip HEAD
@mv META.json.bak META.json
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,20 @@ Community

## SQL Examples


```bash
# Connect to Postgres
psql postgres://postgres:[email protected]:5432/postgres
```

```sql
-- create the extension
-- create the extension in the "pgmq" schema
CREATE EXTENSION pgmq;
```

### Creating a queue

Every queue is its own table in Postgres. The table name is the queue name prefixed with `q_`.
For example, `q_my_queue` is the table for the queue `my_queue`.
Every queue is its own table in the `pgmq` schema. The table name is the queue name prefixed with `q_`.
For example, `pgmq.q_my_queue` is the table for the queue `my_queue`.

```sql
-- creates the queue
Expand Down Expand Up @@ -121,11 +120,11 @@ The message id is returned from the send function.
### Read messages

Read `2` message from the queue. Make them invisible for `30` seconds.
If the messages are not deleted or archived within 30 seconds, they will become visible again
and can be read by another consumer.
If the messages are not deleted or archived within 30 seconds, they will become visible again
and can be read by another consumer.

```sql
SELECT pgmq.read('my_queue', 30, 2);
SELECT * FROM pgmq.read('my_queue', 30, 2);
```

```text
Expand Down Expand Up @@ -161,11 +160,10 @@ SELECT pgmq.pop('my_queue');

### Archive a message

Archiving a message removes it from the queue, and inserts it to the archive table.

Archive message with msg_id=2.
Archiving a message removes it from the queue and inserts it to the archive table.

```sql
-- Archive message with msg_id=2.
SELECT pgmq.archive('my_queue', 2);
```

Expand All @@ -176,8 +174,8 @@ SELECT pgmq.archive('my_queue', 2);
(1 row)
```

Archive tables have the prefix `a_`:
```sql
-- Archive tables have the prefix `a_`:
SELECT * FROM pgmq.a_my_queue;
```

Expand Down

0 comments on commit 3e662a0

Please sign in to comment.