Skip to content

Commit 3d52e77

Browse files
authored
Merge pull request #35 from supabase/release_docs
sync docs with sql
2 parents f909f31 + d3c1cd6 commit 3d52e77

File tree

5 files changed

+58
-15
lines changed

5 files changed

+58
-15
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@
1616

1717
---
1818

19-
A PostgreSQL extension providing an async networking interface accessible via SQL using a [background worker](https://www.postgresql.org/docs/current/bgworker.html) and curl.
19+
pg_net is a PostgreSQL extension exposing a SQL interface for async networking with a focus on scalability and UX.
20+
21+
Features:
22+
23+
- async http GET requests
24+
- async http POST requests with a JSON payload

docs/api.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ net.http_get(
1515
-- url for the request
1616
url text,
1717
-- key/value pairs to be url encoded and appended to the `url`
18-
params jsonb DEFAULT '{}'::jsonb,
18+
params jsonb default '{}'::jsonb,
1919
-- key/values to be included in request headers
20-
headers jsonb DEFAULT '{}'::jsonb,
20+
headers jsonb default '{}'::jsonb,
2121
-- the maximum number of milliseconds the request may take before being cancelled
22-
timeout_milliseconds int DEFAULT 1000
22+
timeout_milliseconds int default 1000
2323
)
2424
-- request_id reference
2525
returns bigint
@@ -63,7 +63,7 @@ net.http_post(
6363
-- key/values to be included in request headers
6464
headers jsonb default '{"Content-Type": "application/json"}'::jsonb,
6565
-- the maximum number of milliseconds the request may take before being cancelled
66-
timeout_milliseconds int DEFAULT 1000
66+
timeout_milliseconds int default 1000
6767
)
6868
-- request_id reference
6969
returns bigint
@@ -78,8 +78,8 @@ net.http_post(
7878
select
7979
net.http_post(
8080
url:='https://httpbin.org/post',
81-
body:='{"hello": "world"}'::jsonb,
82-
);
81+
body:='{"hello": "world"}'::jsonb
82+
) as request_id;
8383
request_id
8484
----------
8585
1
@@ -101,7 +101,7 @@ When `async:=false` is set it is recommended that [statement_timeout](https://ww
101101
```sql
102102
net.http_collect_response(
103103
-- request_id reference
104-
request_id id,
104+
request_id bigint,
105105
-- when `true`, return immediately. when `false` wait for the request to complete before returning
106106
async bool default true
107107
)
@@ -115,7 +115,11 @@ net.http_collect_response(
115115

116116
##### usage
117117
```sql
118-
select net.http_get('https://news.ycombinator.com') as request_id;
118+
select
119+
net.http_post(
120+
url:='https://httpbin.org/post',
121+
body:='{"hello": "world"}'::jsonb
122+
) as request_id;
119123
request_id
120124
----------
121125
1
@@ -125,12 +129,41 @@ select * from net.http_collect_response(1, async:=false);
125129
status | message | response
126130
--------+---------+----------
127131
SUCCESS ok ...
132+
133+
134+
select
135+
(response).body::json
136+
from
137+
net.http_collect_response(request_id:=1);
138+
body
139+
-------------------------------------------------------------------
140+
{
141+
"args": {},
142+
"data": "{\"hello\": \"world\"}",
143+
"files": {},
144+
"form": {},
145+
"headers": {
146+
"Accept": "*/*",
147+
"Content-Length": "18",
148+
"Content-Type": "application/json",
149+
"Host": "httpbin.org",
150+
"User-Agent": "pg_net/0.1",
151+
"X-Amzn-Trace-Id": "Root=1-61031a5c-7e1afeae69bffa8614d8e48e"
152+
},
153+
"json": {
154+
"hello": "world"
155+
},
156+
"origin": "135.63.38.488",
157+
"url": "https://httpbin.org/post"
158+
}
159+
(1 row)
128160
```
161+
129162
where `response` is a composite
163+
130164
```sql
131165
status_code integer
132166
headers jsonb
133167
body text
134168
```
135-
136169
Possible values for `net.http_response_result.status` are `('PENDING', 'SUCCESS', 'ERROR')`

docs/contributing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pg_netis OSS. PR and issues are welcome.
1+
pg_net is OSS. PR and issues are welcome.
22

33

44
## Development
@@ -14,10 +14,10 @@ For testing locally, execute:
1414
$ nix-shell
1515

1616
# test on pg 12
17-
$ net-with-pg-12 make installcheck
17+
$ net-with-pg-12 python -m pytest -vv"
1818
1919
# test on pg 13
20-
$ net-with-pg-13 make installcheck
20+
$ net-with-pg-13 python -m pytest -vv"
2121
```
2222

2323
### Documentation

docs/index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@
1616

1717
---
1818

19-
A PostgreSQL extension providing an async networking interface accessible via SQL using a [background worker](https://www.postgresql.org/docs/current/bgworker.html) and curl.
19+
pg_net is a PostgreSQL extension exposing a SQL interface for async networking with a focus on scalability and UX.
20+
21+
Features:
22+
23+
- async http GET requests
24+
- async http POST requests with a JSON payload

docs/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Tested to work on PostgreSQL 12 and 13.
1+
Tested with PostgreSQL 12 and 13.
22

33
## Setup
44

0 commit comments

Comments
 (0)