Class: Microsandbox::SandboxStopResult

Inherits:
Object
  • Object
show all
Defined in:
lib/microsandbox/sandbox.rb

Overview

The terminal observation of a stopped sandbox, returned by Microsandbox::Sandbox#wait_until_stopped. Mirrors the official SDKs’ ‘SandboxStopResult`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ SandboxStopResult

Returns a new instance of SandboxStopResult.



51
52
53
54
55
56
57
58
# File 'lib/microsandbox/sandbox.rb', line 51

def initialize(data)
  @name = data["name"]
  @status = data["status"].to_sym
  @exit_code = data["exit_code"]
  @signal = data["signal"]
  @source = data["source"]
  @observed_at_ms = data["observed_at_ms"]
end

Instance Attribute Details

#exit_codeInteger? (readonly)

Returns process exit code, when observed from an owned child.

Returns:

  • (Integer, nil)

    process exit code, when observed from an owned child



45
46
47
# File 'lib/microsandbox/sandbox.rb', line 45

def exit_code
  @exit_code
end

#nameString (readonly)

Returns:

  • (String)


41
42
43
# File 'lib/microsandbox/sandbox.rb', line 41

def name
  @name
end

#signalInteger? (readonly)

Returns terminating signal, when observed from an owned child.

Returns:

  • (Integer, nil)

    terminating signal, when observed from an owned child



47
48
49
# File 'lib/microsandbox/sandbox.rb', line 47

def signal
  @signal
end

#sourceString? (readonly)

Returns human description of the observation source.

Returns:

  • (String, nil)

    human description of the observation source



49
50
51
# File 'lib/microsandbox/sandbox.rb', line 49

def source
  @source
end

#statusSymbol (readonly)

Returns :running, :draining, :paused, :stopped, or :crashed.

Returns:

  • (Symbol)

    :running, :draining, :paused, :stopped, or :crashed



43
44
45
# File 'lib/microsandbox/sandbox.rb', line 43

def status
  @status
end

Instance Method Details

#crashed?Boolean

Returns:

  • (Boolean)


61
# File 'lib/microsandbox/sandbox.rb', line 61

def crashed? = @status == :crashed

#inspectObject



68
69
70
71
# File 'lib/microsandbox/sandbox.rb', line 68

def inspect
  "#<Microsandbox::SandboxStopResult name=#{@name.inspect} status=#{@status}" \
    "#{@exit_code ? " exit_code=#{@exit_code}" : ""}#{@signal ? " signal=#{@signal}" : ""}>"
end

#observed_atTime

Returns when the stopped state was observed.

Returns:

  • (Time)

    when the stopped state was observed



64
65
66
# File 'lib/microsandbox/sandbox.rb', line 64

def observed_at
  Time.at(@observed_at_ms / 1000.0)
end

#stopped?Boolean

Returns:

  • (Boolean)


60
# File 'lib/microsandbox/sandbox.rb', line 60

def stopped? = @status == :stopped