/**
* std/waitpoint — durable waitpoints for fan-in, fan-out, and long waits.
*
* Import with: `import "std/waitpoint"`.
*/
type WaitpointStatus = "open" | "completed" | "cancelled"
type Waitpoint = {
id: string,
status: WaitpointStatus,
created_at: string,
completed_at: string?,
cancelled_at: string?,
completed_by: string?,
cancelled_by: string?,
value: any?,
reason: string?,
metadata: any?,
}
type WaitpointWaitOptions = {timeout?: duration}
type WaitpointTerminalOptions = {by?: string, reason?: string, metadata?: any}
type WaitpointTimeoutError = {
name: "WaitpointTimeoutError",
category: "timeout",
message: string,
wait_id: string,
}
type WaitpointCancelledError = {
name: "WaitpointCancelledError",
category: "cancelled",
message: string,
wait_id: string,
waitpoint_ids: list<string>,
reason: string?,
}
/**
* create.
*
* @effects: []
* @allocation: heap
* @errors: []
* @api_stability: stable
* @example: create(id_or_options)
*/
pub fn create(id_or_options = nil) {
if id_or_options == nil {
return __waitpoint_create()
}
return __waitpoint_create(id_or_options)
}
/**
* wait.
*
* @effects: []
* @allocation: heap
* @errors: []
* @api_stability: stable
* @example: wait(waitpoints, options)
*/
pub fn wait(waitpoints, options = nil) {
if options == nil {
return __waitpoint_wait(waitpoints)
}
return __waitpoint_wait(waitpoints, options)
}
/**
* complete.
*
* @effects: []
* @allocation: heap
* @errors: []
* @api_stability: stable
* @example: complete(waitpoint, value, options)
*/
pub fn complete(waitpoint, value, options = nil) {
if options == nil {
return __waitpoint_complete(waitpoint, value)
}
return __waitpoint_complete(waitpoint, value, options)
}
/**
* cancel.
*
* @effects: []
* @allocation: heap
* @errors: []
* @api_stability: stable
* @example: cancel(waitpoint, options)
*/
pub fn cancel(waitpoint, options = nil) {
if options == nil {
return __waitpoint_cancel(waitpoint)
}
return __waitpoint_cancel(waitpoint, options)
}