class
Rosegold::Intervention
- Rosegold::Intervention
- Reference
- Object
Overview
Standing, opt-in permission for an operator to take over a running script.
A takeover gates scripted input at once through ManualControl, then parks
the registered script fiber at its next Bot#wait_tick(s). Only that fiber
ever blocks; the ticker, event handlers and other fibers keep running.
Defined in:
rosegold/control/intervention.crConstructors
Instance Method Summary
- #active? : Bool
-
#can_take_over? : Bool
Whether a takeover could start now: permitted, a script registered, no takeover in progress, no manual grant or release outstanding, and no cancellation still waiting for a live owner's checkpoint.
-
#cancel(grant_id : UInt64, reason : ManualControl::Reason) : Bool
Forced loss or disable of the controller.
-
#checkpoint : Nil
Called by
Bot#wait_tick(s); parks only the fiber the takeover was requested for. - #client : Client
-
#finish_restart : Nil
Called by
Bot.runafter an unwound restart, before the next connection. -
#grant_ended(grant_id : UInt64, reason : ManualControl::Reason, unresolved : Bool) : Nil
Called by
ManualControlwhenever a grant ends, whatever ended it. - #grant_id : UInt64 | Nil
-
#last_cancellation : ManualControl::Cancelled | Nil
The most recent forced cancellation, kept for the companion to report.
- #parked? : Bool
- #pending? : Bool
-
#permitted=(value : Bool)
Turns the standing permission on or off.
- #permitted? : Bool
-
#register_owner(fiber : Fiber = Fiber.current, restartable : Bool = false) : Nil
Registers the fiber that runs the script.
- #release_owner : Nil
-
#request_takeover : UInt64 | Nil
Takes over: gates scripted input and cancels pending intentions now.
-
#reset : Nil
Backstop for a session change.
-
#restart(grant_id : UInt64 | Nil = nil) : Bool
Unwinds the parked script and restarts its
Bot.runblock from the top on a fresh connection. -
#restart_requested? : Bool
Whether a restart was requested and
Bot.runhas not yet handled it. - #restartable? : Bool
-
#resume(grant_id : UInt64 | Nil = nil) : Bool
Ends the takeover and continues the script at the point where it parked.
- #state : State
Constructor Detail
Instance Method Detail
Whether a takeover could start now: permitted, a script registered, no takeover in progress, no manual grant or release outstanding, and no cancellation still waiting for a live owner's checkpoint.
Forced loss or disable of the controller. Rejects a stale grant, revokes
with reason and wakes a parked owner. When inventory work is unresolved,
the owner's checkpoint raises ManualControl::Cancelled rather than
continuing blindly; otherwise it resumes as after a normal return. Either
way the cancellation is kept in #last_cancellation.
Called by Bot#wait_tick(s); parks only the fiber the takeover was requested for.
Called by ManualControl whenever a grant ends, whatever ended it. Resolves
the matching takeover exactly once; a forced end with unresolved inventory
makes the owner's next checkpoint raise.
The most recent forced cancellation, kept for the companion to report.
Turns the standing permission on or off. Turning it off ends a takeover.
Registers the fiber that runs the script. restartable is true only for
Bot.run, which can rebuild the session; a custom runner can resume only.
Takes over: gates scripted input and cancels pending intentions now. Returns the manual grant id, or nil when not permitted, no script is registered, or control is already held. The takeover binds the owner registered when it was requested; if starting the grant revokes it, changes the owner or permission, or starts another takeover, the grant is returned.
Backstop for a session change. ManualControl#reset is the supported
entrypoint and has already delivered any pending cancellation to the old
owner, which survives this call; a later owner never inherits it.
Unwinds the parked script and restarts its Bot.run block from the top on
a fresh connection. Rejected until the script is parked, or when the runner
the takeover was requested for cannot restart.
Whether a restart was requested and Bot.run has not yet handled it.
The unwind raises RestartRequested once, at the parked checkpoint. A user
rescue can swallow that one raise, so Bot.run also checks this flag
after the block returns. Later checkpoints do not raise again, which keeps
an ensure that waits ticks running to completion. Restart is cooperative:
a retry loop that swallows the raise keeps running, and no further takeover,
resume or restart is possible until the block exits.
Ends the takeover and continues the script at the point where it parked.