← Integration Academy

Production Pulse · 3 / 8

React when a job changes

Add an event subscription alongside the timer. The integration now has scheduled and event-driven entry points.

YOUR TASK

Make this happen

3 steps
  1. In events.cococo, subscribe to job.updated.

  2. Connect integration_actor_subscription.job_updates through subscriptions in actor.cococo.

  3. Preserve the heartbeat and its schedule.

This lesson starts with the previous working solution. Build and connect the next capability. Your earlier drafts are kept separately.

Read the starter files

main.cococo

integration_document "monitor" {
  integrationId = "com.academy.monitor"
  sdkVersion = "2.0"
  version = "1.0.0"
  description = "A small heartbeat integration"
  actor = integration_actor.monitor
}

actor.cococo

integration_actor "monitor" {
  timers = [integration_actor_timer.heartbeat, integration_actor_timer.daily_review]
}

timer.cococo

integration_actor_timer "heartbeat" {
  name = "heartbeat"
  schedule = { every = "5m" }
  jitter = "15s"
  source = "return { alive = true }"
}

daily.cococo

integration_actor_timer "daily_review" {
  name = "daily_review"
  schedule = { cron = "0 6 * * *" }
  source = "return { review = true }"
}

events.cococo

integration_actor_subscription "job_updates" {
  # TODO: add topic — see the task above.
  # TODO: add source — see the task above.
}
Supplied scripts and pinned contracts (read-only)

These fixtures explain the runtime behaviour being composed. They are included in validation but are not executed. The generated API definition is supplied, not an XML authoring task.

scripts/heartbeat.lua

return { alive = true }

scripts/job-updated.lua

local event, config = ...
return { reason = "job.updated" }