Class: Kobako::SandboxOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/kobako/sandbox_options.rb

Overview

Kobako::SandboxOptions — immutable Value Object holding the four per-Sandbox configuration caps (docs/behavior.md B-01, E-20). Built on the class X < Data.define(…) subclass form (the Steep-friendly shape — see lib/kobako/outcome/panic.rb).

The initialize method does double duty: it applies DEFAULT fallback for absent values and normalises (timeout to Float seconds, memory_limit to positive Integer bytes) before delegating to Data’s super. Anything that survives SandboxOptions.new is a wire-ready cap bundle the Kobako::Wasm::Instance constructor consumes as-is.

Constant Summary collapse

DEFAULT_TIMEOUT_SECONDS =

Default wall-clock timeout for a single invocation: 60 seconds (docs/behavior.md B-01).

60.0
DEFAULT_MEMORY_LIMIT =

Default cap on the per-invocation guest linear-memory delta: 1 MiB (docs/behavior.md B-01). The mruby image’s initial allocation and prior invocations’ watermark sit outside this budget — see B-01 Notes.

1 << 20
DEFAULT_OUTPUT_LIMIT =

Default per-channel capture ceiling: 1 MiB (docs/behavior.md B-01).

1 << 20

Instance Method Summary collapse

Constructor Details

#initialize(timeout: DEFAULT_TIMEOUT_SECONDS, memory_limit: DEFAULT_MEMORY_LIMIT, stdout_limit: nil, stderr_limit: nil) ⇒ SandboxOptions

steep:ignore:start



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kobako/sandbox_options.rb', line 31

def initialize(timeout: DEFAULT_TIMEOUT_SECONDS,
               memory_limit: DEFAULT_MEMORY_LIMIT,
               stdout_limit: nil,
               stderr_limit: nil)
  super(
    timeout: normalize_timeout(timeout),
    memory_limit: normalize_memory_limit(memory_limit),
    stdout_limit: stdout_limit || DEFAULT_OUTPUT_LIMIT,
    stderr_limit: stderr_limit || DEFAULT_OUTPUT_LIMIT
  )
end