From def42b298f0a5c5025cf3124b3f1d2fedf806e76 Mon Sep 17 00:00:00 2001 From: Wojtek Majewski Date: Wed, 22 Jan 2025 20:13:08 +0100 Subject: [PATCH] docs(readme): Update Edge Worker documentation with detailed overview Enhance README with comprehensive project information: - Add centered header with documentation link - Include alpha stage warning - Describe project purpose and key features - Add architecture diagram explanation - Highlight Edge Function optimization details - Provide documentation reference --- pkgs/edge-worker/README.md | 43 ++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/pkgs/edge-worker/README.md b/pkgs/edge-worker/README.md index 90c42ed..4af7f9f 100644 --- a/pkgs/edge-worker/README.md +++ b/pkgs/edge-worker/README.md @@ -1,7 +1,42 @@ -# Edge Worker +
+

Edge Worker

+ +

📚 Documentation @ pgflow.dev

+
+ +

⚠️ ALPHA STAGE - NOT PRODUCTION READY ⚠️

+
-This library was generated with [Nx](https://nx.dev). +A task queue worker for Supabase Edge Functions that extends background tasks with useful features. -## Running unit tests +## What is Edge Worker? + +Edge Worker processes messages from a queue and executes user-defined functions with their payloads. It builds upon [Supabase Background Tasks](https://supabase.com/docs/guides/functions/background-tasks) to add reliability features like retries, concurrency control and monitoring. + +## Key Features + +- ⚡ **Reliable Processing**: Retries with configurable delays +- 🔄 **Concurrency Control**: Limit parallel task execution +- 📊 **Observability**: Built-in heartbeats and logging +- 📈 **Horizontal Scaling**: Deploy multiple edge functions for the same queue +- 🛡️ **Edge-Native**: Designed for Edge Functions' CPU/clock limits + +## How It Works + +[![Architecture Diagram](https://mermaid.ink/img/pako:eNplkcFugzAMhl8lyrl9AQ47VLBxqdSqlZAGHEziASokyEkmTaXvvoR0o1VziGL_n_9Y9pULLZEnvFItwdSxc1op5o9xTUxU_OQmaMAgy2SL7N0pYXutTMUjGU5WlItYaLog1VFAJSv14paCXdweyw8f-2MZLnZ06LBelXxXRk_DztAM-Gp9KA-kpRP-W7bdvs3Ga4aNaAy0OC_WdzD4B4IQVsLMvvkIZMUiA4mu_8ZHYjW5MxNp4dUnKC9zUHJA-h9R_VQTG-sQyDYINlTs-IaPSCP00q_gGvCK2w5HP53EPyXQJczp5jlwVp9-lOCJJYcbTtq13V_gJgkW0x78lEeefMFgfHYC9an1GqPsraZ9XPiy99svlAqmtA?type=png)](https://mermaid.live/edit#pako:eNplkcFugzAMhl8lyrl9AQ47VLBxqdSqlZAGHEziASokyEkmTaXvvoR0o1VziGL_n_9Y9pULLZEnvFItwdSxc1op5o9xTUxU_OQmaMAgy2SL7N0pYXutTMUjGU5WlItYaLog1VFAJSv14paCXdweyw8f-2MZLnZ06LBelXxXRk_DztAM-Gp9KA-kpRP-W7bdvs3Ga4aNaAy0OC_WdzD4B4IQVsLMvvkIZMUiA4mu_8ZHYjW5MxNp4dUnKC9zUHJA-h9R_VQTG-sQyDYINlTs-IaPSCP00q_gGvCK2w5HP53EPyXQJczp5jlwVp9-lOCJJYcbTtq13V_gJgkW0x78lEeefMFgfHYC9an1GqPsraZ9XPiy99svlAqmtA) + +## Edge Function Optimization + +Edge Worker is specifically designed to handle Edge Function limitations: + +- Stops polling near CPU/clock limits +- Gracefully aborts pending tasks +- Uses PGMQ's visibility timeout to prevent message loss +- Auto-spawns new instances for continuous operation +- Monitors worker health with database heartbeats + + +## Documentation + +For detailed documentation and getting started guide, visit [pgflow.dev](https://pgflow.dev). -Run `nx test edge-worker` to execute the unit tests