Types
Cancellation core
Cancellation type {
$msg: Str,
$data: Any
}
Represents a cancelled execution. Created by cancel().
Example
c cancel("User cancelled", {"reason": "timeout"})
c.$msg // "User cancelled"
c.$data // {"reason": "timeout"}
Failure core
Failure type {
$msg: Str,
$err: Any
}
Represents a failed execution. Created by fail().
Example
f fail("Connection failed", {"host": "api.example.com"})
f.$msg // "Connection failed"
f.$err // {"host": "api.example.com"}
Build
Build type {
id: Uuid?,
hash: Str?
}
Env
Env type {
id: Uuid?,
name: Str?
}
Org
Org type {
id: Uuid?
}
Project
Project type {
id: Uuid?,
name: Str?
}
Run
Run type {
id: Uuid,
type: Str,
status: Str,
start-time: ::hot::time/Instant,
retry-attempt: Int,
max-retries: Int,
retry-delay: Int,
origin-run-id: Uuid?
}
RunInfo
RunInfo type {
run: Run,
stream: Stream,
build: Build,
project: Project,
env: Env,
user: User,
org: Org
}
Stream
Stream type {
id: Uuid
}
User
User type {
id: Uuid?
}
Functions
cancel core
fn (msg: Str): Cancellation
fn (msg: Str, lazy data: Any): Cancellation
Cancel the current run. Halts execution gracefully.
Example
// Simple cancellation
cancel("Operation cancelled by user")
// Cancellation with data
cancel("Task timeout", {"elapsed": 30000})
exit core
fn (code: Int)
Exit the current execution with status code.
Behavior varies by context:
- CLI: Exits the process with the given code
- Worker:
exit(0)completes successfully;exit(N)acts likefail()
Example
// Exit successfully
exit(0)
// Exit with error code (will fail on worker)
exit(1)
fail core
fn (lazy err: Any): Failure
fn (msg: Str, lazy err: Any): Failure
Fail with err or msg and err. Halts execution immediately.
Example
// Simple failure
fail("Something went wrong")
// Failure with details
fail("Validation failed", {"field": "email", "error": "invalid format"})
// Conditional failure
if(is-empty(users), fail("No users found"), first(users))
info core
fn (): RunInfo
Return information about the current run execution context.
Returns a RunInfo containing details about the run, stream, build, project, env, user, and org.
Optional fields return null when not available.
Example
i info()
i.run.id // UUID of the current run
i.run.type // "call", "event", "schedule", "run", "eval", or "repl"
i.run.status // "running"
i.run.start-time // Instant when the run started
i.run.retry-attempt // Current retry attempt (0 = first try, 1 = first retry, etc.)
i.run.max-retries // Maximum retries from function meta (0 = no retries)
i.run.retry-delay // Delay between retries in milliseconds
i.run.origin-run-id // UUID of original run if this is a retry (null otherwise)
i.build.hash // Build hash (null if not available)
i.project.name // Project name (null if not available)
i.env.id // Environment UUID (null if not available)
is-inline-run core
fn ()
Is the run type a direct run type (vs. scheduled or event triggered)