Skip to content

Commit 6fadf8d

Browse files
committed
build: add Makefile for PGXS
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
1 parent 309f539 commit 6fadf8d

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
EXTENSION = pg_dispatch
2+
EXTVERSION = 0.1.2
3+
DATA = pg_dispatch--0.1.2.sql
4+
5+
PG_CONFIG ?= pg_config
6+
PGXS := $(shell $(PG_CONFIG) --pgxs)
7+
include $(PGXS)
8+
9+
.PHONY: dist
10+
dist:
11+
mkdir -p dist
12+
git archive --format zip --prefix=$(EXTENSION)-$(EXTVERSION)/ -o dist/$(EXTENSION)-$(EXTVERSION).zip HEAD

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
> A [TLE](https://github.com/aws/pg_tle) compliant alternative to [pg_later](https://github.com/ChuckHend/pg_later).
44
5-
An asynchronous task dispatcher for PostgreSQL that helps unblock your main transaction by offloading heavy SQL as deferrable jobs.
5+
An asynchronous task dispatcher for PostgreSQL that helps unblock your main transaction by offloading heavy SQL as deferrable jobs, allowing you to run SQL queries asynchronously.
66

7-
This is meant to be a [TLE](https://github.com/aws/pg_tle) compliant alternative to [pg_later](https://github.com/ChuckHend/pg_later) built on top of [`pg_cron`](https://github.com/citusdata/pg_cron), which means you can easily use it in sandboxed environments like Supabase and AWS RDS.
7+
This is meant to be a [TLE](https://github.com/aws/pg_tle) compliant alternative to [pg_later](https://github.com/ChuckHend/pg_later) built on top of [pg_cron](https://github.com/citusdata/pg_cron), which means you can easily use it in sandboxed environments like Supabase and AWS RDS.
88

99
## Use cases
1010

11-
This extension is particularly useful when writing database-native server-side logic (in something like PL/pgSQL) and wanting to dispatch **_side-effects_** asynchronously.
11+
This extension is particularly useful when writing database-native server-side logic (in something like PL/pgSQL) and wanting to dispatch **_side-effects_** asynchronously in a separate transaction.
1212

1313
Say you have an `AFTER INSERT` trigger on a user profiles table that is called every time a new user hops in by calling an [RPC (remote procedure call)](https://docs.postgrest.org/en/v12/references/api/functions.html).
1414
You can offload the bulky and asynchronous **_side-effects_** (written as PostgreSQL functions), such as sending notifications to other users or updating large tables storing analytics, thereby unblocking your main RPC, for which btw, the client is still waiting for a response from.
@@ -21,19 +21,21 @@ You can offload the bulky and asynchronous **_side-effects_** (written as Postgr
2121

2222
## Installation
2323

24-
Install via [database.dev](https://database.dev/Snehil-Shah/pg_dispatch):
24+
Install via [database.dev](https://database.dev/Snehil_Shah/pg_dispatch):
2525

2626
```sql
27-
SELECT dbdev.install(Snehil-Shah@pg_dispatch);
27+
SELECT dbdev.install(Snehil_Shah@pg_dispatch);
2828
```
2929

30+
To learn how to install `dbdev` and published TLE extensions, read [here](https://supabase.github.io/dbdev/install-in-db-client/).
31+
3032
> [!WARNING]
3133
> This extension is installed in the `pgdispatch` schema and can potentially cause namespace collisions if you already had one before.
3234
3335
## Usage
3436

3537
```sql
36-
CREATE EXTENSION "Snehil-Shah@pg_dispatch";
38+
CREATE EXTENSION "Snehil_Shah@pg_dispatch";
3739
```
3840

3941
<!-- <docs> -->

pg_dispatch--0.1.2.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ COMMENT ON SCHEMA pgdispatch IS
2121
'Reserved for the pg_dispatch extension';
2222

2323
/**
24-
* (internal) ### pgdispatch._schedule_job
24+
* (internal) ### pgdispatch._schedule_job( command TEXT, delay INTERVAL )
2525
*
26-
* Internal function for scheduling temporary cron jobs
26+
* Internal function for scheduling temporary cron jobs.
2727
*
2828
* #### Parameters:
2929
* - **command** (`TEXT`) - The SQL statement to execute
@@ -89,7 +89,7 @@ COMMENT ON FUNCTION pgdispatch._schedule_job(TEXT, INTERVAL) IS
8989
/**
9090
* ### pgdispatch.fire( command TEXT )
9191
*
92-
* Dispatches an SQL command for asynchronous execution
92+
* Dispatches an SQL command for asynchronous execution.
9393
*
9494
* ```sql
9595
* SELECT pgdispatch.fire('SELECT pg_sleep(40);');
@@ -114,7 +114,7 @@ COMMENT ON FUNCTION pgdispatch.fire(TEXT) IS
114114
/**
115115
* ### pgdispatch.snooze( command TEXT, delay INTERVAL )
116116
*
117-
* Dispatches a delayed SQL command for asynchronous execution
117+
* Dispatches a delayed SQL command for asynchronous execution.
118118
*
119119
* ```sql
120120
* SELECT pgdispatch.snooze('SELECT pg_sleep(20);', '20 seconds');

0 commit comments

Comments
 (0)