Skip to content

Commit

Permalink
Revert "fix: remove timeout_milliseconds option"
Browse files Browse the repository at this point in the history
This reverts commit 31fe586.
  • Loading branch information
soedirgo committed Jul 30, 2021
1 parent 31fe586 commit bedcdd8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
10 changes: 8 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ net.http_get(
-- key/value pairs to be url encoded and appended to the `url`
params jsonb default '{}'::jsonb,
-- key/values to be included in request headers
headers jsonb default '{}'::jsonb
headers jsonb default '{}'::jsonb,
-- WARNING: this is currently ignored, so there is no timeout
-- the maximum number of milliseconds the request may take before being cancelled
timeout_milliseconds int default 1000
)
-- request_id reference
returns bigint
Expand Down Expand Up @@ -59,7 +62,10 @@ net.http_post(
-- key/value pairs to be url encoded and appended to the `url`
params jsonb default '{}'::jsonb,
-- key/values to be included in request headers
headers jsonb default '{"Content-Type": "application/json"}'::jsonb
headers jsonb default '{"Content-Type": "application/json"}'::jsonb,
-- WARNING: this is currently ignored, so there is no timeout
-- the maximum number of milliseconds the request may take before being cancelled
timeout_milliseconds int default 1000
)
-- request_id reference
returns bigint
Expand Down
20 changes: 14 additions & 6 deletions sql/pg_net--0.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ create table net.http_request_queue(
url text not null,
headers jsonb not null,
body bytea,
-- TODO: respect this
timeout_milliseconds int not null,
created timestamptz not null default now()
);

Expand Down Expand Up @@ -91,7 +93,9 @@ create or replace function net.http_get(
-- key/value pairs to be url encoded and appended to the `url`
params jsonb default '{}'::jsonb,
-- key/values to be included in request headers
headers jsonb default '{}'::jsonb
headers jsonb default '{}'::jsonb,
-- the maximum number of milliseconds the request may take before being cancelled
timeout_milliseconds int default 1000
)
-- request_id reference
returns bigint
Expand All @@ -109,11 +113,12 @@ begin
from jsonb_each_text(params);

-- Add to the request queue
insert into net.http_request_queue(method, url, headers)
insert into net.http_request_queue(method, url, headers, timeout_milliseconds)
values (
'GET',
net._encode_url_with_params_array(url, params_array),
headers
headers,
timeout_milliseconds
)
returning id
into request_id;
Expand All @@ -132,7 +137,9 @@ create or replace function net.http_post(
-- key/value pairs to be url encoded and appended to the `url`
params jsonb default '{}'::jsonb,
-- key/values to be included in request headers
headers jsonb default '{"Content-Type": "application/json"}'::jsonb
headers jsonb default '{"Content-Type": "application/json"}'::jsonb,
-- the maximum number of milliseconds the request may take before being cancelled
timeout_milliseconds int DEFAULT 1000
)
-- request_id reference
returns bigint
Expand Down Expand Up @@ -180,12 +187,13 @@ begin
jsonb_each_text(params);

-- Add to the request queue
insert into net.http_request_queue(method, url, headers, body)
insert into net.http_request_queue(method, url, headers, body, timeout_milliseconds)
values (
'POST',
net._encode_url_with_params_array(url, params_array),
headers,
body::text::bytea
body::text::bytea,
timeout_milliseconds
)
returning id
into request_id;
Expand Down

0 comments on commit bedcdd8

Please sign in to comment.