Skip to content

Commit

Permalink
Merge branch 'main' into guide-bloom
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHStanton authored Oct 18, 2023
2 parents a00016a + 72e6592 commit 7059304
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
29 changes: 29 additions & 0 deletions contrib/pg_bm25/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG PG_VERSION=15
FROM quay.io/coredb/pgrx-builder:pg${PG_VERSION}-pgrx0.9.7
USER root

ARG RELEASE=v0.2.21

# Extension build dependencies
RUN apt-get update && apt-get install -y \
build-essential

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Set default Rust version
RUN /root/.cargo/bin/rustup default stable && /root/.cargo/bin/rustup override set 1.72.0

# Clone repository
RUN git clone /~https://github.com/paradedb/paradedb.git && \
cd paradedb && \
git fetch --tags && \
git fetch --depth 1 origin tag ${RELEASE} && \
git checkout ${RELEASE}


# Build the extension
RUN cd paradedb && \
cd pg_bm25 && \
cargo pgrx init --pg15 /usr/bin/pg_config && \
cargo pgrx package
22 changes: 22 additions & 0 deletions contrib/pg_bm25/Trunk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[extension]
name = "pg_bm25"
version = "0.4.0"
repository = "/~https://github.com/paradedb/paradedb/tree/dev/pg_bm25"
license = "AGPL-3.0"
description = "Full text search over SQL tables using the state-of-the-art BM25 algorithm"
homepage = "https://www.paradedb.com/"
documentation = "/~https://github.com/paradedb/paradedb/tree/dev/pg_bm25"
categories = ["search"]

[dependencies]
apt = ["libc6"]

[build]
postgres_version = "15"
platform = "linux/amd64"
dockerfile = "Dockerfile"
install_command = """
cd paradedb/
mv target/release/pg_bm25-pg15/usr/lib/postgresql/15/lib/* /usr/lib/postgresql/15/lib
mv target/release/pg_bm25-pg15/usr/share/postgresql/15/extension/* /usr/share/postgresql/15/extension
"""
43 changes: 43 additions & 0 deletions contrib/pgmq/Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# What is this extension?

> Lightweight message queue.
`pgmq` is a rust-based extension designed to implement message queues. It uses technologies also associated with Kafka, RabbitMQ, and SQS.

# When should you use it?

This extension can be used when you’re interested in managing operational pipelines, especially in asynchronous tasks and distributed systems. It is also worth considering when you need features like guaranteed exactly-once delivery, optional archival for replay-ability, and the familiarity of SQL for managing your queues.

# Example use case.

A newly-founded Postgres startup requires a job queue to manage tasks between their control-plane and data-plane within their managed cloud offering. They needed operations like "create postgres cluster" and "update postgres cluster" to be queued and executed seamlessly. To simplify their architecture and reduce technology sprawl, they implemented `pgmq`, creating an efficient message queue system directly within Postgres.

# Example test script.

```
-- Creating a new queue
SELECT pgmq.create('my_queue');
-- Sending messages to the queue
SELECT * FROM pgmq.send('my_queue', '{"foo": "bar1"}');
SELECT * FROM pgmq.send('my_queue', '{"foo": "bar2"}');
-- Reading messages from the queue and making them invisible for a duration
SELECT * FROM pgmq.read('my_queue', 30, 2);
-- If the queue is empty or all messages are invisible, it returns no rows
SELECT * FROM pgmq.read('my_queue', 30, 1);
-- Archiving a message
SELECT * FROM pgmq.archive('my_queue', 2);
-- Viewing the archived message
SELECT * FROM pgmq.a_my_queue;
-- Sending another message and then deleting it
SELECT pgmq.send('my_queue', '{"foo": "bar3"}');
SELECT pgmq.delete('my_queue', 3);
-- Drop queue(s) to complete example
SELECT pgmq.drop_queue('my_queue');
```

0 comments on commit 7059304

Please sign in to comment.