Class Supaworker<Payload>

A worker that processes jobs from a queue. Use createSupaworker to create a new worker.

Type Parameters

  • Payload

Constructors

Methods

Constructors

  • Type Parameters

    • Payload

    Parameters

    • client: SupabaseClient<
          Database,
          "supaworker",
          {
              CompositeTypes: {};
              Enums: {};
              Functions: {
                  dequeue: {
                      Args: { queue_name: string };
                      Returns: {
                          attempts: number;
                          created_at: string;
                          enabled: boolean;
                          id: number;
                          options: Json;
                          payload: Json;
                          queue: string;
                      }[];
                  };
              };
              Tables: {
                  jobs: {
                      Insert: {
                          attempts?: number;
                          created_at?: string;
                          enabled?: boolean;
                          id?: number;
                          options?: Json;
                          payload?: Json;
                          queue: string;
                      };
                      Relationships: [];
                      Row: {
                          attempts: number;
                          created_at: string;
                          enabled: boolean;
                          id: number;
                          options: Json;
                          payload: Json;
                          queue: string;
                      };
                      Update: {
                          attempts?: number;
                          created_at?: string;
                          enabled?: boolean;
                          id?: number;
                          options?: Json;
                          payload?: Json;
                          queue?: string;
                      };
                  };
                  logs: {
                      Insert: {
                          created_at?: string;
                          id?: string;
                          job: Json;
                          status: string;
                      };
                      Relationships: [];
                      Row: { created_at: string; id: string; job: Json; status: string };
                      Update: {
                          created_at?: string;
                          id?: string;
                          job?: Json;
                          status?: string;
                      };
                  };
              };
              Views: {};
          },
      >
    • enqueue: EnqueueFunction<Payload>
    • work: SupaworkerHandler<Payload>
    • options: SupaworkerOptions

    Returns Supaworker<Payload>

Methods

  • Start working on the queue.

    Returns Promise<void>

  • Stop working on the queue.

    Returns Promise<void>