Repository navigation
Automations are Harbor's: the record, the pages, starting one and the tick (0.22.0) - #27
Merged
Merged
Conversation
… tick Harbor::Automation is the record, on the automations table (the migration creates it when it is missing, and adds the index and foreign key on runs.automation_id). Harbor::AutomationsController serves /factory/automations: the list, the form that makes and edits one, the switch, "Run now" and Delete. The menu's Automations entry is the engine's own route. Harbor::Automations::Dispatch starts one however it was triggered, always as a tracked run or a stated reason not to. Harbor::Automations::Tick starts every scheduled automation that came due, exactly once: a compare-and-set on last_scheduled_at, once for the latest time missed after an outage, and a start that raises is handed back for the next tick. Harbor::Automations::TickJob is the one entry a site gives its scheduler; Harbor requires none in particular. A site with no code of its own makes an agent automation on the page, its schedule fires it, and Harbor::Automations::AgentRunJob runs it as an agent session of its agent, waiting while the agent or every runtime is full. A slash command is read from the ref in the new automation_command_ref setting. A job automation enqueues one of the site's own job classes (loader, skill or self). They are made in code: the page never saves job_class, job_dispatch, job_input or kind. A host declares categories, working folders, identities, field labels and trigger kinds of its own (Harbor::Automations), names its subclass (automation_class), says which of its attributes the form saves (automation_params), reads the rest of the form (automation_edited), and may run agent automations its own way (automation_agent_run). It adds to the pages with partials in its own app/views/harbor/automations/: _name_extras, _agent_fields, _trigger_fields and _hint. fugit is a dependency. 0.22.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 6a of moving the Factory's sections into Harbor: Automations and the tick. Version 0.22.0.
What a site with no code of its own gets
/factory/automations: the list, the form that makes and edits an automation, the switch, "Run now" and Delete.Harbor::Automations::AgentRunJobruns it as an agent session of its agent. While the agent or every runtime is full, or no model is available, the run waits and the job looks again.Harbor::Automations::TickJob, the one entry a site gives its scheduler, every minute. Harbor requires no scheduler in particular; the README shows sidekiq-scheduler, Solid Queue and a plain call.What Harbor owns now
Harbor::Automationon theautomationstable. The migration creates the table only when it is missing, and adds the index and foreign key onruns.automation_idonly when they are missing, so it changes nothing in a host that already has them.next_run_at,due_at, the trigger in words, and the marker that makes a schedule count from when it was set.Harbor::Automations::Dispatch: starts an automation however it was triggered, as a tracked run or a stated reason not to.Harbor::Automations::Tick: starts each due automation exactly once (a compare-and-set onlast_scheduled_at), once for the latest time missed after an outage, and hands a due time back when the start raises.kind: "job", withjob_dispatchloader,skillorself). They are made in code. The page never savesjob_class,job_dispatch,job_inputorkind, so a name typed in a browser is never turned into a constant.What a host declares, configures and adds
Harbor::Automations.category,.working_folder,.identity,.labeland.trigger(a trigger kind the host fires itself).config.automation_class,config.automation_params,config.automation_editedandconfig.automation_agent_run(for a host that runs agent automations its own way).app/views/harbor/automations/:_name_extras,_agent_fields,_trigger_fieldsand_hint.automation_command_ref,origin/mainby default).Tests
test/automations_test.rb(the record, the declarations, starting one, the session job, the tick) andtest/automations_pages_test.rb(the pages, with and without a host's additions). They include a site with no host code making an automation on the page, the tick starting a due one exactly once, and a disabled or not-due one being left alone. The dummy app's placeholder page for "a page still in the host" is Workflows now, since Automations is Harbor's.669 runs, 0 failures; rubocop clean.
Upgrading
See "Upgrading from 0.21" in the CHANGELOG. The one thing every site does is schedule the tick.