SSE
Enable Server-Sent Events (SSE) streaming for the endpoint.
Keywords
sse, sse_events_path, sse_path
Syntax
sse <path>
sse <path> on <level>level: info, notice, warning
Examples
Basic SSE Endpoint
sql
create function long_running_process(_id int)
returns void
language plpgsql
as $$
begin
raise notice 'Starting process...';
-- do work
raise notice 'Progress: 50%%';
-- more work
raise notice 'Complete!';
end;
$$;
comment on function long_running_process(int) is
'HTTP POST
sse /process/events';With Notice Level
sql
comment on function background_task() is
'HTTP POST
sse /task/updates on notice';Warning Level Only
sql
comment on function critical_job() is
'HTTP POST
sse /job/alerts on warning';Behavior
- Creates an SSE endpoint at the specified path
- PostgreSQL
RAISEstatements become SSE events - Clients connect to SSE path to receive real-time updates
- Use correlation headers to match SSE events to requests
Related
- NpgsqlRest Options configuration - Configure SSE options
- Comment Annotations Guide - How annotations work
- Configuration Guide - How configuration works
Related Annotations
- SSE_EVENTS_LEVEL - Set notice level
- SSE_EVENTS_SCOPE - Set distribution scope