Add Job and Action tracking for runner with GRPC notifications
Motivation and Context
Track runner job state in the database so the UI can display current runner activity. Previously, job execution was ephemeral with no persistence layer for monitoring.
Description
Adds database-backed job and action tracking with GRPC notifications from runner to gocast main instance.
New Models & DAO:
-
model/job.go- Job entity with unifiedWorkStatetype (created/running/completed/failed/cancelled) and timestamps -
model/action.go- Action entity with its own table, referencing jobs via foreign key, storing action type as string,WorkStatestatus, timestamps, andLastErrorfor error tracking -
dao/job.go- CRUD operations for both jobs and actions, queries by job ID, stream ID, runner hostname, active status
Protobuf Extensions:
- Unified
WorkStateenum used by both jobs and actions -
JobUpdateNotificationmessage for job state changes (status only, no error field) -
ActionUpdateNotificationmessage for individual action state changes (uses string for action_type, includeslast_error)
Runner Changes:
-
RunAction()sends separate job and action status notifications - Job notifications at creation, running state, and completion/failure/cancellation
- Action notifications for each action start, completion, and failure (errors tracked at action level)
- Action type is stored as plain string (e.g., "stream", "mk_vod", "check_vod")
- Safe stream version enum conversion with fallback to
STREAM_VERSION_UNSPECIFIED
Manager Changes:
-
handleJobUpdate()persists job state on notification receipt -
handleActionUpdate()persists action state, creating new action records or updating existing ones - Single
protoWorkStateToModel()converter for the unified WorkState type
Model Relations:
-
Runner.Jobs- foreign key relationship to active jobs -
Stream.Jobs- foreign key relationship to associated jobs -
Job.Actions- foreign key relationship to actions within a job -
RunnerDao.GetAllWithJobs()- preloads active jobs for UI queries
Steps for Testing
Prerequisites:
- Runner connected to gocast instance
- Database access to verify jobs and actions tables
- Trigger a stream request to a runner
- Verify job record created in
jobstable with statuscreated - Verify action records created in
actionstable for each action (stream, mk_vod, etc.) - Observe job status transitions:
created→running→completed - Observe action status transitions:
running→completedfor each action - Cancel a stream mid-execution, verify job status becomes
cancelled - Force an action failure, verify action status becomes
failedwithlast_errorpopulated, and job status becomesfailed
Screenshots
N/A - Backend changes only. UI integration pending separate PR.
Original prompt
Look at the current implementation of the runner with the actions and jobs.
Depict this functionality in the database and create GRPC notifications from the runner and the gocast main instance, such that the database always has the current state so I can show this in the UI
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
@copilot I removed the lastError from the job. That is more of an action thing. Please clean up the notifications and notify about action updates where required.
@copilot I removed the lastError from the job. That is more of an action thing. Please clean up the notifications and notify about action updates where required.
Removed LastError from the Job model and JobUpdateNotification protobuf in 750ad42. Errors are now tracked only at the action level via ActionUpdateNotification.