Module: RSMP::Proxy::Modules::State

Included in:
RSMP::Proxy
Defined in:
lib/rsmp/proxy/modules/state.rb

Overview

State management helpers Utility methods for waiting on state changes

Instance Method Summary collapse

Instance Method Details

#handshake_completeObject



29
30
31
32
# File 'lib/rsmp/proxy/modules/state.rb', line 29

def handshake_complete
  build_sxl_interfaces
  self.state = :ready
end

#wait_for_state(state, timeout:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rsmp/proxy/modules/state.rb', line 7

def wait_for_state(state, timeout:)
  states = [state].flatten
  return Result.success(@state) if states.include?(@state)

  result = wait_for_condition(@state_condition, timeout: timeout) do
    states.include?(@state)
  end
  return Result.success(@state) if result.success?

  Result.failure(
    :timeout,
    message: "Did not reach state #{state} within #{timeout}s",
    source: :timeout,
    context: { expected: states, actual: @state },
    cause: result.failure.cause
  )
end

#wait_for_state!Object



25
26
27
# File 'lib/rsmp/proxy/modules/state.rb', line 25

def wait_for_state!(...)
  wait_for_state(...).value!
end