Class: Browserctl::Workflow::RecoveryManager
- Inherits:
-
Object
- Object
- Browserctl::Workflow::RecoveryManager
- Defined in:
- lib/browserctl/workflow/recovery_manager.rb
Overview
Owns the AUTH_REQUIRED recovery state machine for load_state.
When the daemon reports AUTH_REQUIRED on a state_load (e.g. expired
cookies in the bundle), the manager either runs the bound flow or
the caller-provided override, re-saves the bundle, and reloads it
with skip_auth_check: true.
Decoupled from ContextualPersistence so the multi-step recovery
logic has a dedicated home and a dedicated spec. The host context
only needs to expose client (for daemon RPCs) and invoke (for
running the bound flow); see ContextualPersistence#load_state.
Constant Summary collapse
- AUTH_REQUIRED_CODE =
"AUTH_REQUIRED"
Class Method Summary collapse
-
.auth_required?(res) ⇒ Boolean
True when
resis the daemon's AUTH_REQUIRED preflight signal.
Instance Method Summary collapse
-
#initialize(context) ⇒ RecoveryManager
constructor
A new instance of RecoveryManager.
-
#recover(state_name, initial_res, on_auth_required: nil) ⇒ Object
Run recovery for
state_namegiven the daemon's initial AUTH_REQUIRED response.
Constructor Details
#initialize(context) ⇒ RecoveryManager
Returns a new instance of RecoveryManager.
21 22 23 |
# File 'lib/browserctl/workflow/recovery_manager.rb', line 21 def initialize(context) @context = context end |
Class Method Details
.auth_required?(res) ⇒ Boolean
True when res is the daemon's AUTH_REQUIRED preflight signal.
26 27 28 |
# File 'lib/browserctl/workflow/recovery_manager.rb', line 26 def self.auth_required?(res) (res[:code] || res["code"]) == AUTH_REQUIRED_CODE end |
Instance Method Details
#recover(state_name, initial_res, on_auth_required: nil) ⇒ Object
Run recovery for state_name given the daemon's initial AUTH_REQUIRED
response. Returns the merged retry result (with rotated: true) or
raises Browserctl::WorkflowError when no flow is bound and no override is
supplied, or when the post-rotation reload still fails.
39 40 41 42 43 44 45 46 47 |
# File 'lib/browserctl/workflow/recovery_manager.rb', line 39 def recover(state_name, initial_res, on_auth_required: nil) if on_auth_required on_auth_required.call else invoke_bound_flow(state_name, initial_res) end rotate_and_reload(state_name) end |