Explorer

definy.io

description
A program that does I/O through the host and ends with a value of type A (docs/structured-concurrency.md). done(value) ends it. all runs the tasks concurrently and passes all the results (in order) to then; race passes the result of the first task that ends and cancels the others. A task never outlives the program that started it, because then is called only after the tasks end (structured concurrency: there is no handle to a running task). sleep waits ms milliseconds. wait_signal waits until send_signal with the same key is done (by this program or by another request on the same host) and passes its payload; send_signal wakes all the programs waiting for the key and passes how many. With race, a task can be cancelled from outside (POST /cancel) without a handle. handle sends an HTTP request like handle of wasi:http/handler (WASI 0.3. The host puts the values of secret_headers just before sending, only to the URLs allowed for the secret). The other tags ask the host to do one I/O (the store, signatures, ...) and continue with then. A host that cannot do an I/O ends the program with an error. definy.service-io and wasi.io are this type with a fixed A
type
Fn(A: Type) -> Type
expression
fn(A$0) =>
  Union{
    #done($0),
    #all(Record{
      Child: Type,
      tasks: List<@definy.io(A: Param("Child"))>,
      then: Fn(results: List<Param("Child")>) -> @definy.io(A: $0)
    }),
    #race(Record{
      Child: Type,
      tasks: List<@definy.io(A: Param("Child"))>,
      then: Fn(result: Param("Child")) -> @definy.io(A: $0)
    }),
    #sleep(Record{ms: Number, then: Fn(slept_ms: Number) -> @definy.io(A: $0)}),
    #wait_signal(Record{key: String, then: Fn(payload: String) -> @definy.io(A: $0)}),
    #send_signal(Record{key: String, payload: String, then: Fn(woken: Number) -> @definy.io(A: $0)}),
    #handle(Record{
      request: @http.request,
      secret_headers: List<Record{name: String, prefix: String, secret: Secret}>,
      then: Fn(result: @http.result) -> @definy.io(A: $0)
    }),
    #get_parts(Record{
      ids: List<String>,
      then: Fn(parts: List<Record{id: String, expression: @core.expression}>) -> @definy.io(A: $0)
    }),
    #verify_ed25519(Record{
      public_key: List<Number>,
      signature: List<Number>,
      message: List<Number>,
      then: Fn(valid: Boolean) -> @definy.io(A: $0)
    }),
    #read_time(Record{then: Fn(now_ms: Number) -> @definy.io(A: $0)}),
    #hash_contents(Record{
      contents_bytes: List<String>,
      then: Fn(hashes: List<Union{#none, #some(String)}>) -> @definy.io(A: $0)
    }),
    #read_admin_account_ids(Record{then: Fn(admin_account_ids: String) -> @definy.io(A: $0)}),
    #sql(Record{
      statements: List<@definy.sql-statement>,
      then: Fn(results: List<List<@definy.sql-row>>) -> @definy.io(A: $0)
    }),
    #read_seed_status(Record{then: Fn(status: @definy.seed-status) -> @definy.io(A: $0)}),
    #read_seed_bundle(Record{then: Fn(bundle: Union{#none, #some(@definy.seed-bundle)}) -> @definy.io(A: $0)}),
    #mark_seeded(Record{then: Fn(marked: Boolean) -> @definy.io(A: $0)}),
    #read_cached_commits(Record{
      event_hashes: List<String>,
      then: Fn(cached: List<@definy.snapshot-cache-entry>) -> @definy.io(A: $0)
    }),
    #write_cached_commits(Record{entries: List<@definy.snapshot-cache-entry>, then: Fn(written: Boolean) -> @definy.io(A: $0)}),
    #read_cached_definitions(Record{
      content_hashes: List<String>,
      then: Fn(cached: List<@definy.definition-cache-entry>) -> @definy.io(A: $0)
    }),
    #write_cached_definitions(Record{entries: List<@definy.definition-cache-entry>, then: Fn(written: Boolean) -> @definy.io(A: $0)}),
    #read_cached_resolutions(Record{
      content_hashes: List<String>,
      then: Fn(cached: List<@definy.resolution-cache-entry>) -> @definy.io(A: $0)
    }),
    #write_cached_resolutions(Record{entries: List<@definy.resolution-cache-entry>, then: Fn(written: Boolean) -> @definy.io(A: $0)}),
    #read_mcp_account(Record{then: Fn(account: Union{#none, #some(@definy.mcp-account)}) -> @definy.io(A: $0)}),
    #sign_mcp_account(Record{
      message: List<Number>,
      then: Fn(signature: Union{#none, #some(List<Number>)}) -> @definy.io(A: $0)
    }),
    #read_perf_records(Record{
      authorization: String,
      limit: Number,
      path_contains: String,
      then: Fn(result: Record{status: Number, body: String}) -> @definy.io(A: $0)
    }),
    #read_host_settings(Record{
      then: Fn(settings: Record{run_expressions: Boolean, storage: String, has_assets: Boolean}) -> @definy.io(A: $0)
    }),
    #run_wasi_io(Record{
      wasm: String,
      parts: List<@definy.wasi-io-part>,
      then: Fn(result: @definy.wasi-io-run-result) -> @definy.io(A: $0)
    }),
    #read_secrets(Record{then: Fn(secrets: List<@definy.secret-info>) -> @definy.io(A: $0)}),
    #write_secret(Record{
      id: String,
      label: String,
      value: String,
      allowed_url_prefixes: List<String>,
      then: Fn(written: Boolean) -> @definy.io(A: $0)
    })
  }
visibility
public
definy.io (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: tNgO-GFaWzuUt4EFC7agC3R6bJ0VGxMWEQtLF-R5sgg
content hash: 8D4ySq8Ow7aC_rBOFJ3UTAPQ-wrOptk0onQII9-S3so