Skip to content

Support for onSchedule #60

Description

@fwal

@effect-firebase/admin wraps callable, request, Firestore document, task queue, and Pub/Sub triggers — but not scheduled functions. Cron jobs still have to use firebase-functions/v2/scheduler's onSchedule directly and hand-roll the Effect runtime bootstrapping that the other wrappers provide.

Motivation

Scheduled functions are a staple of most Firebase backends (cleanup jobs, digests, syncs). They're often the same code that already runs inside Effect via the other wrappers, so the missing wrapper forces an awkward seam: either wrap the handler body in a manual Runtime.runPromise, or keep scheduled functions outside Effect entirely.

Suggested shape

An onScheduleEffect in the style of the existing wrappers (onCallEffect, onTaskDispatchedEffect, onMessagePublishedEffect):

export const cleanup = onScheduleEffect(
  { schedule: 'every 24 hours' },
  (event) =>
    Effect.gen(function* () {
      // ...
    }),
  runtime
);

Scheduled events carry no payload beyond ScheduledEvent metadata (jobName, scheduleTime), so no schema decoding is needed — this should be one of the simpler triggers to add.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions