Module: Kobako::Outcome

Defined in:
lib/kobako/outcome.rb,
sig/kobako/outcome.rbs

Overview

Host-facing boundary for the invocation outcome the native side split off the core envelope. Takes the arm it named plus the fields that arm carries, and settles the invocation the way a host does: return the value, or raise the exception the failure attributes to.

This is the two-step attribution decision. The wire framing belongs to the native side; the payload codec at Kobako::Codec decodes only the one arm that carries a value.

Constant Summary collapse

ORIGIN_SANDBOX =

The two origin values a Panic attributes with.

Returns:

  • (String)
"sandbox"
ORIGIN_SERVICE =

Returns:

  • (String)
"service"
SUBCLASSES =

The guest-written class names that select a SandboxError subclass. A name absent here settles as plain SandboxError, so the guest widens the taxonomy only by naming a class the host already defines.

Returns:

{
  "Kobako::BytecodeError" => BytecodeError,
  "Kobako::UndefinedEntrypointError" => UndefinedEntrypointError
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reify(kind, payload, panic, entrypoint: nil) ⇒ Object

Settle one invocation. kind names the arm, payload is the codec-encoded value the :ok arm carries, and panic carries the Panic's fields [origin, class, message, backtrace, available] — present on the panic arm and absent on every other, which is what tells the failure that has a record to attribute from apart from the two that do not. entrypoint is the name this invocation asked for, which the host knows and the wire therefore never carries.



37
38
39
40
41
# File 'lib/kobako/outcome.rb', line 37

def reify(kind, payload, panic, entrypoint: nil)
  return decode_value(payload) if kind == :ok

  raise panic ? panic_error(panic, entrypoint) : trap_error(kind)
end

Instance Method Details

#self?.decode_valueKobako::Codec::wire_value

Parameters:

  • payload (String)

Returns:

  • (Kobako::Codec::wire_value)


19
# File 'sig/kobako/outcome.rbs', line 19

def self?.decode_value: (String payload) -> Kobako::Codec::wire_value

#self?.error_classsingleton(SandboxError), singleton(ServiceError)

Parameters:

  • origin (String)
  • klass (String)

Returns:



15
# File 'sig/kobako/outcome.rbs', line 15

def self?.error_class: (String origin, String klass) -> (singleton(SandboxError) | singleton(ServiceError))

#self?.panic_errorSandboxError, ServiceError

Everything below is private_class_method at runtime; RBS cannot mark a self? method private, so the declarations stay visible to the checker.

Parameters:

  • panic (panic_fields)
  • entrypoint (Symbol, nil)

Returns:



13
# File 'sig/kobako/outcome.rbs', line 13

def self?.panic_error: (panic_fields panic, Symbol? entrypoint) -> (SandboxError | ServiceError)

#self?.reifyKobako::Codec::wire_value

Parameters:

  • kind (Symbol)
  • payload (String)
  • panic (panic_fields, nil)
  • entrypoint: (Symbol, nil)

Returns:

  • (Kobako::Codec::wire_value)


9
# File 'sig/kobako/outcome.rbs', line 9

def self?.reify: (Symbol kind, String payload, panic_fields? panic, ?entrypoint: Symbol?) -> Kobako::Codec::wire_value

#self?.trap_errorTrapError

Parameters:

  • kind (Symbol)

Returns:



17
# File 'sig/kobako/outcome.rbs', line 17

def self?.trap_error: (Symbol kind) -> TrapError

#self?.wire_errorTransport::Error

Parameters:

  • message (String)
  • diagnostic: (String, nil)

Returns:



21
# File 'sig/kobako/outcome.rbs', line 21

def self?.wire_error: (String message, ?diagnostic: String?) -> Transport::Error