GCP.CloudScheduler reference
Source:
src/GCP/CloudScheduler/Job.ts
A Cloud Scheduler job that invokes an HTTP, Pub/Sub, or App Engine target on a cron schedule.
Jobs have no labels field, so ownership rests on the deterministic job
name: read reports a job it finds without prior state as unowned
(adopt it with --adopt). Name and location are immutable; changing
either replaces the job.
Job: Creating a Job
Section titled “Job: Creating a Job”Generated name, yearly HTTP GET
const ping = yield* GCP.CloudScheduler.Job("Ping", { schedule: "0 0 1 1 *", paused: true, httpTarget: { uri: "https://example.com/", httpMethod: "GET", },});Named job with retries and a POST body
const notify = yield* GCP.CloudScheduler.Job("Notify", { jobId: "order-notify", location: "us-central1", schedule: "every 15 minutes", timeZone: "America/Chicago", description: "fan out order events", retryConfig: { retryCount: 3, minBackoffDuration: "10s" }, httpTarget: { uri: "https://example.com/hooks/orders", httpMethod: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ source: "scheduler" }), },});Pub/Sub target
const tick = yield* GCP.CloudScheduler.Job("Tick", { schedule: "0 * * * *", pubsubTarget: { topicName: topic.name, data: "tick", },});PauseJob
Section titled “PauseJob”Source:
src/GCP/CloudScheduler/PauseJob.ts
Runtime binding for Cloud Scheduler jobs.pause.
Bind this operation to a Job in a Function/Action init phase.
Provide PauseJobHttp.
Grants roles/cloudscheduler.admin on the project: it is the only
predefined role with cloudscheduler.jobs.pause, and Cloud Scheduler has
neither per-job IAM policies nor IAM Conditions on resource.name.
PauseJob: Pausing Jobs
Section titled “PauseJob: Pausing Jobs”const pauseJob = yield* GCP.CloudScheduler.PauseJob(ping);yield* pauseJob();PauseJobHttp
Section titled “PauseJobHttp”Source:
src/GCP/CloudScheduler/PauseJobHttp.tsKind: Layer · Provides:GCP.CloudScheduler.PauseJob
HTTP implementation of PauseJob.
Grants roles/cloudscheduler.admin on the project because it is the
only predefined role with cloudscheduler.jobs.pause, and Cloud Scheduler
supports neither per-job IAM policies nor IAM Conditions on
resource.name.
ResumeJob
Section titled “ResumeJob”Source:
src/GCP/CloudScheduler/ResumeJob.ts
Runtime binding for Cloud Scheduler jobs.resume.
Bind this operation to a Job in a Function/Action init phase.
Provide ResumeJobHttp.
Grants roles/cloudscheduler.admin on the project: it is the only
predefined role with cloudscheduler.jobs.enable, and Cloud Scheduler has
neither per-job IAM policies nor IAM Conditions on resource.name.
ResumeJob: Resuming Jobs
Section titled “ResumeJob: Resuming Jobs”const resumeJob = yield* GCP.CloudScheduler.ResumeJob(ping);yield* resumeJob();ResumeJobHttp
Section titled “ResumeJobHttp”Source:
src/GCP/CloudScheduler/ResumeJobHttp.tsKind: Layer · Provides:GCP.CloudScheduler.ResumeJob
HTTP implementation of ResumeJob.
Grants roles/cloudscheduler.admin on the project because it is the
only predefined role with cloudscheduler.jobs.enable, and Cloud Scheduler
supports neither per-job IAM policies nor IAM Conditions on
resource.name.
RunJob
Section titled “RunJob”Source:
src/GCP/CloudScheduler/RunJob.ts
Runtime binding for Cloud Scheduler jobs.run.
Forces an immediate dispatch even if the job is already running. Bind this
operation to a Job in a Function/Action init phase. Provide
RunJobHttp.
RunJob: Running Jobs
Section titled “RunJob: Running Jobs”const runJob = yield* GCP.CloudScheduler.RunJob(ping);yield* runJob();RunJobHttp
Section titled “RunJobHttp”Source:
src/GCP/CloudScheduler/RunJobHttp.tsKind: Layer · Provides:GCP.CloudScheduler.RunJob
HTTP implementation of RunJob.
ScheduleEventSource
Section titled “ScheduleEventSource”Source:
src/GCP/CloudScheduler/ScheduleEventSource.ts
Event source that invokes the hosting compute on a Cloud Scheduler schedule — the “cron handler” DX.
The HTTP-host implementation is GCP.Run.ScheduleEventSource
(GCP.Function / GCP.Run.Service, GCP.CloudFunctions.Function): it
creates a Cloud Scheduler job that POSTs to the host with an OIDC
token for the host’s runtime service account, grants that account
roles/run.invoker on the host, and verifies the token on every
invocation. A failed handler answers 500 and the job’s retry policy
applies.
Consume it through consumeSchedule.
ScheduleEventSource: Consuming a Schedule
Section titled “ScheduleEventSource: Consuming a Schedule”Nightly cleanup on a Cloud Run service
export class Api extends GCP.Function<Api>()( "Api", { main: import.meta.url }, Effect.gen(function* () { yield* GCP.CloudScheduler.consumeSchedule( "NightlyCleanup", { schedule: "0 3 * * *", timeZone: "America/New_York" }, (event) => Effect.log(`cleanup scheduled for ${event.scheduleTime}`), ); }).pipe(Effect.provide(GCP.Run.ScheduleEventSource)),) {}Pass a fixed payload
yield* GCP.CloudScheduler.consumeSchedule( "Digest", { schedule: "every 1 hours", body: JSON.stringify({ kind: "digest" }) }, (event) => sendDigest(JSON.parse(event.body ?? "{}")),);