Interface SidetrackService<Queues>

interface SidetrackService<Queues extends SidetrackQueuesGenericType> {
    cancelJob: (
        jobId: string,
        options?: SidetrackCancelJobOptions,
    ) => Effect<void>;
    deactivateCronSchedule: <K extends string | number | symbol>(
        queueName: K,
        cronExpression: string,
        options?: SidetrackDeactivateCronScheduleOptions,
    ) => Effect<void>;
    deleteCronSchedule: <K extends string | number | symbol>(
        queueName: K,
        cronExpression: string,
        options?: SidetrackDeleteCronScheduleOptions,
    ) => Effect<void>;
    deleteJob: (
        jobId: string,
        options?: SidetrackDeleteJobOptions,
    ) => Effect<void>;
    getJob: (
        jobId: string,
        options?: SidetrackGetJobOptions,
    ) => Effect<SidetrackJobs>;
    insertJob: <K extends string | number | symbol>(
        queueName: K,
        payload: Queues[K],
        options?: SidetrackInsertJobOptions,
    ) => Effect<SidetrackJobs>;
    scheduleCron: <K extends string | number | symbol>(
        queueName: K,
        cronExpression: string,
        payload: Queues[K],
        options?: SidetrackCronJobOptions,
    ) => Effect<SidetrackCronJobs, ParseError>;
    start: () => Effect<void>;
    stop: () => void;
    testUtils: {
        listJobs: <K extends string | number | symbol>(
            options?: SidetrackListJobsOptions<Queues, K>,
        ) => Effect<SidetrackJobs[]>;
        listJobStatuses: <K extends string | number | symbol>(
            options?: SidetrackListJobStatusesOptions<Queues, K>,
        ) => Effect<Partial<Record<SidetrackJobStatusEnum, number>>>;
        runJob: (
            jobId: string,
            options?: SidetrackRunJobOptions,
        ) => Effect<void, unknown>;
        runJobs: <K extends string | number | symbol>(
            options?: SidetrackRunJobsOptions<Queues, K>,
        ) => Effect<void, unknown>;
    };
}

Type Parameters

Properties

cancelJob: (jobId: string, options?: SidetrackCancelJobOptions) => Effect<void>
deactivateCronSchedule: <K extends string | number | symbol>(
    queueName: K,
    cronExpression: string,
    options?: SidetrackDeactivateCronScheduleOptions,
) => Effect<void>

Deactivate a cron schedule. This prevents the cron schedule from creating new jobs.

Type declaration

    • <K extends string | number | symbol>(
          queueName: K,
          cronExpression: string,
          options?: SidetrackDeactivateCronScheduleOptions,
      ): Effect<void>
    • Type Parameters

      • K extends string | number | symbol

      Parameters

      Returns Effect<void>

deleteCronSchedule: <K extends string | number | symbol>(
    queueName: K,
    cronExpression: string,
    options?: SidetrackDeleteCronScheduleOptions,
) => Effect<void>

Delete a cron schedule. This removes the cron job from the database.

Type declaration

    • <K extends string | number | symbol>(
          queueName: K,
          cronExpression: string,
          options?: SidetrackDeleteCronScheduleOptions,
      ): Effect<void>
    • Type Parameters

      • K extends string | number | symbol

      Parameters

      Returns Effect<void>

deleteJob: (jobId: string, options?: SidetrackDeleteJobOptions) => Effect<void>
getJob: (
    jobId: string,
    options?: SidetrackGetJobOptions,
) => Effect<SidetrackJobs>
insertJob: <K extends string | number | symbol>(
    queueName: K,
    payload: Queues[K],
    options?: SidetrackInsertJobOptions,
) => Effect<SidetrackJobs>
scheduleCron: <K extends string | number | symbol>(
    queueName: K,
    cronExpression: string,
    payload: Queues[K],
    options?: SidetrackCronJobOptions,
) => Effect<SidetrackCronJobs, ParseError>

Schedule a cron job on a queue

Type declaration

    • <K extends string | number | symbol>(
          queueName: K,
          cronExpression: string,
          payload: Queues[K],
          options?: SidetrackCronJobOptions,
      ): Effect<SidetrackCronJobs, ParseError>
    • Type Parameters

      • K extends string | number | symbol

      Parameters

      • queueName: K

        The queue to schedule the cron job on

      • cronExpression: string

        A 5 or 6 part cron expression

      • payload: Queues[K]
      • Optionaloptions: SidetrackCronJobOptions

      Returns Effect<SidetrackCronJobs, ParseError>

start: () => Effect<void>

Automatically run migrations and start polling the DB for jobs

stop: () => void

Turn off polling

testUtils: {
    listJobs: <K extends string | number | symbol>(
        options?: SidetrackListJobsOptions<Queues, K>,
    ) => Effect<SidetrackJobs[]>;
    listJobStatuses: <K extends string | number | symbol>(
        options?: SidetrackListJobStatusesOptions<Queues, K>,
    ) => Effect<Partial<Record<SidetrackJobStatusEnum, number>>>;
    runJob: (
        jobId: string,
        options?: SidetrackRunJobOptions,
    ) => Effect<void, unknown>;
    runJobs: <K extends string | number | symbol>(
        options?: SidetrackRunJobsOptions<Queues, K>,
    ) => Effect<void, unknown>;
}

Utilities meant to be used with tests only

Type declaration