Class: Protege::ResponsibilityRun
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Protege::ResponsibilityRun
- Defined in:
- app/models/protege/responsibility_run.rb
Overview
One execution of a Responsibility — the Loop layer's run-state record and audit trail.
The scheduler creates a run pending and enqueues a ResponsibilityJob; the job marks it
running (stamping started_at) and then completed or failed (stamping finished_at and, on
failure, the error class and message). The dashboard reads these rows to show a responsibility's
recent history.
Instance Method Summary collapse
-
#mark_completed! ⇒ void
Mark this run completed, stamping
finished_at. -
#mark_failed!(error) ⇒ void
Mark this run failed, recording the error class and message and stamping
finished_at. -
#start! ⇒ void
Mark this run as running now: stamp
started_at, snapshot the current correlation id (minted by the job, so the run row links to the events it emits), and keep the responsibility's denormalisedlast_run_atfresh (it is running, so the responsibility has just run) — mirroring howMessagekeeps its thread's counters current.
Instance Method Details
#mark_completed! ⇒ void
This method returns an undefined value.
Mark this run completed, stamping finished_at.
51 52 53 |
# File 'app/models/protege/responsibility_run.rb', line 51 def mark_completed! update!(status: :completed, finished_at: Time.current) end |
#mark_failed!(error) ⇒ void
This method returns an undefined value.
Mark this run failed, recording the error class and message and stamping finished_at.
59 60 61 62 63 64 65 66 |
# File 'app/models/protege/responsibility_run.rb', line 59 def mark_failed!(error) update!( status: :failed, finished_at: Time.current, error_class: error.class.name, error_message: error. ) end |
#start! ⇒ void
This method returns an undefined value.
Mark this run as running now: stamp started_at, snapshot the current correlation id (minted by
the job, so the run row links to the events it emits), and keep the responsibility's denormalised
last_run_at fresh (it is running, so the responsibility has just run) — mirroring how Message
keeps its thread's counters current.
42 43 44 45 46 |
# File 'app/models/protege/responsibility_run.rb', line 42 def start! now = Time.current update!(status: :running, started_at: now, correlation_id: Protege::Current.correlation_id) responsibility.update!(last_run_at: now) end |