Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build from source instructions #19

Merged
merged 4 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Postgres Message Queue (PGMQ)
# Contributing to Postgres Message Queue (PGMQ)

## Installation

Expand All @@ -8,44 +8,68 @@ The fastest way to get started is by running the Tembo docker image, where PGMQ
docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 quay.io/tembo/pgmq-pg:latest
```

# Development
## Building from source

Setup `pgrx`.
PGMQ is written as a Rust extension and requires [pgrx](https://github.com/pgcentralfoundation/pgrx).

To build pgmq from source, you need
* A toolchain capable of building Postgres
* Rust toolchain
* [pg_partman](https://github.com/pgpartman/pg_partman).

Once you have those pre-requisites, you need to setup `pgrx`.

```bash
cargo install --locked cargo-pgrx
cargo pgrx init
cargo install --locked cargo-pgrx --version 0.9.8
```

Then, clone this repo and change into this directory.
Clone the repo and change into the directory.

```bash
git clone git@https://github.com/tembo-io/pgmq.git
git clone https://github.com/tembo-io/pgmq.git
cd pgmq
```

### Setup dependencies
After this point, the steps differ slightly based on if you'd like to build
and install against an existing Postgres setup or develop against pgrx managed
development environment (which installs and allows you to test against multiple
Postgres versions).

Install:
- [pg_partman](https://github.com/pgpartman/pg_partman), which is required for partitioned tables.
### Install to a pre-existing Postgres

Initialize `cargo-pgrx`, and tell it the path to the your `pg_config`. For example,
if `pg_config` is on your `$PATH` and you have Postgres 15, you can run:

Update postgresql.conf in the development environment.
```bash
cargo pgrx init --pg15=`which pg_config`
```
Then, to install the release build, you can simply run:
```
cargo pgrx install --release
```
# ~/.pgrx/data-14/postgresql.conf
shared_preload_libraries = 'pg_partman_bgw'

### Install against pgrx managed Postgres (Recommended for Development)

Initialize `cargo-pgrx` development environment:

```bash
cargo pgrx init
```

**Note**: Make sure you build and install `pg_partman` against the postgres installation
you want to build against (`PG_CONFIG` in `~/.pgrx/PG_VERSION/pgrx-install/bin/pg_config`
and `PGDATA` in `/Users/samaysharma/.pgrx/data-PG_MAJOR_VERSION`)

Run the dev environment
Then, you can use the run command, which will build and install the extension
and drop you into psql:

```bash
cargo pgrx run pg15
```

Create the extension
Finally, you can create the extension and get started with the example in the [README.md](README.md).

```pql
```psql
CREATE EXTENSION pgmq cascade;
```

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ The fastest way to get started is by running the Tembo docker image, where PGMQ
docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 quay.io/tembo/pgmq-pg:latest
```

If you'd like to build from source, you can follow the instructions in [CONTRIBUTING.md](CONTRIBUTING.md)

## Client Libraries


Expand Down Expand Up @@ -222,7 +224,7 @@ Add the following to `postgresql.conf`. Note, changing `shared_preload_libraries
`pg_partman_bgw.interval` sets the interval at which `pg_partman` conducts maintenance. This creates new partitions and dropping of partitions falling out of the `retention_interval`. By default, `pg_partman` will keep 4 partitions "ahead" of the currently active partition.

```
shared_preload_libraries = 'pg_partman_bgw' # requires restart of Postgrs
shared_preload_libraries = 'pg_partman_bgw' # requires restart of Postgres
pg_partman_bgw.interval = 60
pg_partman_bgw.role = 'postgres'
pg_partman_bgw.dbname = 'postgres'
Expand Down
Loading