Class: Microsandbox::PingResult

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

Overview

The result of Sandbox#ping / SandboxHandle#ping: a lightweight health check that confirms the guest agent is reachable without refreshing the sandbox idle timer. Mirrors the official SDKs' SandboxPingResult.

The native layer reports latency as seconds; #latency is the canonical value and #latency_ms the convenience the Python/Node SDKs expose.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PingResult

Returns a new instance of PingResult.



16
17
18
19
# File 'lib/microsandbox/modification.rb', line 16

def initialize(data)
  @name = data["name"]
  @latency = data["latency_secs"]
end

Instance Attribute Details

#latencyFloat (readonly)

Returns round-trip latency in seconds.

Returns:

  • (Float)

    round-trip latency in seconds



14
15
16
# File 'lib/microsandbox/modification.rb', line 14

def latency
  @latency
end

#nameString (readonly)

Returns the sandbox name that was pinged.

Returns:

  • (String)

    the sandbox name that was pinged



12
13
14
# File 'lib/microsandbox/modification.rb', line 12

def name
  @name
end

Instance Method Details

#inspectObject



26
27
28
# File 'lib/microsandbox/modification.rb', line 26

def inspect
  "#<Microsandbox::PingResult name=#{@name.inspect} latency_ms=#{format("%.3f", latency_ms)}>"
end

#latency_msFloat

Returns round-trip latency in milliseconds.

Returns:

  • (Float)

    round-trip latency in milliseconds



22
23
24
# File 'lib/microsandbox/modification.rb', line 22

def latency_ms
  @latency * 1000.0
end