mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 14:49:10 +03:00
remove refs to api in queues integration doc
This commit is contained in:
1 parent
e38d8691f8
commit
264a9ef9e2
3 files changed
+2
-175
No files matched your search
@@ -1183,7 +1183,6 @@ export const queues: NavMenuConstant = {
|
||||
name: 'References',
|
||||
url: undefined,
|
||||
items: [
|
||||
{ name: 'API', url: '/guides/queues/api' },
|
||||
{ name: 'PGMQ Extension', url: '/guides/queues/pgmq' },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
---
|
||||
title: API
|
||||
---
|
||||
|
||||
{/* <!-- vale off --> */}
|
||||
When you create a Queue in Supabase, you can choose to create helper database functions in the `pgmq_public` schema. This schema exposes operations to manage Queue Messages to consumers client-side, but does not expose functions for creating or dropping Queues.
|
||||
|
||||
Database functions in `pgmq_public` can be exposed via Supabase Data API so consumers client-side can call them. Visit the [Quickstart](/docs/guides/queues/quickstart) for an example.
|
||||
|
||||
### `pgmq_public.pop(queue_name)`
|
||||
|
||||
Retrieves the next available message and deletes it from the specified Queue.
|
||||
|
||||
- `queue_name` (text): Queue name
|
||||
|
||||
---
|
||||
|
||||
### `pgmq_public.send(queue_name, message, sleep_seconds)`
|
||||
|
||||
Adds a Message to the specified Queue, optionally delaying its visibility to all consumers by a number of seconds.
|
||||
|
||||
- `queue_name` (text): Queue name
|
||||
- `message` (jsonb): Message payload to send
|
||||
- `sleep_seconds` (integer, optional): Delay message visibility by specified seconds. Defaults to 0
|
||||
|
||||
---
|
||||
|
||||
### `pgmq_public.send_batch(queue_name, messages, sleep_seconds)`
|
||||
|
||||
Adds a batch of Messages to the specified Queue, optionally delaying their availability to all consumers by a number of seconds.
|
||||
|
||||
- `queue_name` (text): Queue name
|
||||
- `messages` (jsonb[]): Array of message payloads to send
|
||||
- `sleep_seconds` (integer, optional): Delay messages visibility by specified seconds. Defaults to 0
|
||||
|
||||
---
|
||||
|
||||
### `pgmq_public.archive(queue_name, message_id)`
|
||||
|
||||
Archives a Message by moving it from the Queue table to the Queue's archive table.
|
||||
|
||||
- `queue_name` (text): Queue name
|
||||
- `message_id` (bigint): ID of the Message to archive
|
||||
|
||||
---
|
||||
|
||||
### `pgmq_public.delete(queue_name, message_id)`
|
||||
|
||||
Permanently deletes a Message from the specified Queue.
|
||||
|
||||
- `queue_name` (text): Queue name
|
||||
- `message_id` (bigint): ID of the Message to delete
|
||||
|
||||
---
|
||||
|
||||
### `pgmq_public.read(queue_name, sleep_seconds, n)`
|
||||
|
||||
Reads up to "n" Messages from the specified Queue with an optional "sleep_seconds" (visibility timeout).
|
||||
|
||||
- `queue_name` (text): Queue name
|
||||
- `sleep_seconds` (integer): Visibility timeout in seconds
|
||||
- `n` (integer): Maximum number of Messages to read
|
||||
@@ -4,7 +4,7 @@ subtitle: 'Learn how to use Supabase Queues to add and read messages'
|
||||
---
|
||||
|
||||
{/* <!-- vale off --> */}
|
||||
This guide is an introduction to interacting with Supabase Queues via the Dashboard and official client library. Check out [Queues API Reference](/docs/guides/queues/api) for more details on our API.
|
||||
This guide is an introduction to interacting with Supabase Queues via the Dashboard. Check out [Queues SQL API Reference](/docs/guides/queues/pgmq) for more details on the SQL API.
|
||||
|
||||
## Concepts
|
||||
|
||||
@@ -83,29 +83,9 @@ A "Basic Queue" will create `pgmq.q_<queue_name>` and `pgmq.a_<queue_name>` tabl
|
||||
|
||||
However, an "Unlogged Queue" will create `pgmq.q_<queue_name>` as an unlogged table for better performance while sacrificing durability. The `pgmq.a_<queue_name>` table will still be created as a logged table so your archived messages remain safe and secure.
|
||||
|
||||
## Expose Queues to client-side consumers
|
||||
|
||||
Queues, by default, are not exposed over Supabase Data API and are only accessible via Postgres clients.
|
||||
|
||||
However, you may grant client-side consumers access to your Queues by enabling the Supabase Data API and granting permissions to the Queues API, which is a collection of database functions in the `pgmq_public` schema that wraps the database functions in the `pgmq` schema.
|
||||
|
||||
This is to prevent direct access to the `pgmq` schema and its tables (RLS is not enabled by default on any tables) and database functions.
|
||||
|
||||
To get started, navigate to the Queues [Settings page](/dashboard/project/_/integrations/queues/settings) and toggle on “Expose Queues via PostgREST”. Once enabled, Supabase creates and exposes a `pgmq_public` schema containing database function wrappers to a subset of `pgmq`'s database functions.
|
||||
|
||||
<Image
|
||||
alt="Screenshot of Queues settings with toggle to expose to PostgREST"
|
||||
src={{
|
||||
dark: '/docs/img/queues-quickstart-settings.png',
|
||||
light: '/docs/img/queues-quickstart-settings.png',
|
||||
}}
|
||||
/>
|
||||
|
||||
### Enable RLS on your tables in `pgmq` schema
|
||||
|
||||
For security purposes, you must enable Row Level Security (RLS) on all Queue tables (all tables in `pgmq` schema that begin with `q_`) if the Data API is enabled.
|
||||
|
||||
You’ll want to create RLS policies for any Queues you want your client-side consumers to interact with.
|
||||
For security purposes, you may want to enable Row Level Security (RLS) on Queue tables (all tables in `pgmq` schema that begin with `q_`).
|
||||
|
||||
<Image
|
||||
alt="Screenshot of creating an RLS policy from the Queues settings"
|
||||
@@ -115,93 +95,3 @@ You’ll want to create RLS policies for any Queues you want your client-side co
|
||||
}}
|
||||
/>
|
||||
|
||||
### Grant permissions to `pgmq_public` database functions
|
||||
|
||||
On top of enabling RLS and writing RLS policies on the underlying Queue tables, you must grant the correct permissions to the `pgmq_public` database functions for each Data API role.
|
||||
|
||||
The permissions required for each Queue API database function:
|
||||
|
||||
| **Operations** | **Permissions Required** |
|
||||
| ------------------- | ------------------------ |
|
||||
| `send` `send_batch` | `Select` `Insert` |
|
||||
| `read` `pop` | `Select` `Update` |
|
||||
| `archive` `delete` | `Select` `Delete` |
|
||||
|
||||
To manage your queue permissions, click on the Queue Settings button.
|
||||
|
||||
<Image
|
||||
alt="Screenshot of accessing queue settings"
|
||||
src={{
|
||||
dark: '/docs/img/queues-quickstart-queue-settings.png',
|
||||
light: '/docs/img/queues-quickstart-queue-settings.png',
|
||||
}}
|
||||
/>
|
||||
|
||||
Then enable the required roles permissions.
|
||||
|
||||
<Image
|
||||
alt="Screenshot of configuring API access for roles from the Queues settings"
|
||||
src={{
|
||||
dark: '/docs/img/queues-quickstart-roles.png',
|
||||
light: '/docs/img/queues-quickstart-roles-light.png',
|
||||
}}
|
||||
/>
|
||||
|
||||
<Admonition type="note">
|
||||
|
||||
`postgres` and `service_role` roles should never be exposed client-side.
|
||||
|
||||
</Admonition>
|
||||
|
||||
### Enqueuing and dequeuing messages
|
||||
|
||||
Once your Queue has been created, you can begin enqueuing and dequeuing Messages.
|
||||
|
||||
Here's a TypeScript example using the official Supabase client library:
|
||||
|
||||
```tsx
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabaseUrl = 'supabaseURL'
|
||||
const supabaseKey = 'supabaseKey'
|
||||
|
||||
const supabase = createClient(supabaseUrl, supabaseKey)
|
||||
|
||||
const QueuesTest: React.FC = () => {
|
||||
//Add a Message
|
||||
const sendToQueue = async () => {
|
||||
const result = await supabase.schema('pgmq_public').rpc('send', {
|
||||
queue_name: 'foo',
|
||||
message: { hello: 'world' },
|
||||
sleep_seconds: 30,
|
||||
})
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
//Dequeue Message
|
||||
const popFromQueue = async () => {
|
||||
const result = await supabase.schema('pgmq_public').rpc('pop', { queue_name: 'foo' })
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<h2 className="text-2xl font-bold mb-4">Queue Test Component</h2>
|
||||
<button
|
||||
onClick={sendToQueue}
|
||||
className="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600 mr-4"
|
||||
>
|
||||
Add Message
|
||||
</button>
|
||||
<button
|
||||
onClick={popFromQueue}
|
||||
className="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600"
|
||||
>
|
||||
Pop Message
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default QueuesTest
|
||||
```
|
||||
Reference in new issue
Block a user