ExecutionPlane.HTTP (ExecutionPlaneHttp v0.2.0)

Copy Markdown View Source

Helper surface for unary HTTP request/response execution.

Callers provide semantic request data plus optional lineage or envelope overrides. This helper emits HttpExecutionIntent.v1, resolves the matching minimal route, and executes the request through the kernel.

start_unary/2, await_unary/2, and cancel_unary/2 provide a lightweight cancelable lifecycle over the same kernel and protocol path. Cancellation is delegated to the request-owning process so the real :httpc request is cancelled rather than merely abandoning the caller's wait.

Summary

Functions

Awaits a cancelable unary session's terminal kernel result.

Cancels an active unary session.

Starts a cancelable unary HTTP execution.

Functions

await_unary(session, timeout \\ :infinity)

Awaits a cancelable unary session's terminal kernel result.

If timeout expires, the underlying request is cancelled before {:error, :timeout} is returned.

cancel_unary(session, reason)

@spec cancel_unary(ExecutionPlane.HTTP.UnarySession.t(), term()) ::
  :ok | {:error, term()}

Cancels an active unary session.

The request-owning worker acknowledges cancellation only after the lower ExecutionPlane.Protocols.HTTP.cancel_request/1 call has run. Repeated cancellation and cancellation after normal completion are harmless. A normal response that already won the asynchronous completion/cancellation race may still be the terminal result. The cancellation reason is lifecycle metadata and is not copied into the execution outcome.

start_unary(request, opts \\ [])

@spec start_unary(map() | keyword(), keyword()) ::
  {:ok, ExecutionPlane.HTTP.UnarySession.t()}
  | {:error, ExecutionPlane.Kernel.ExecutionResult.t() | term()}

Starts a cancelable unary HTTP execution.

For real HTTP requests this returns after :httpc has assigned the active request identifier. Lower-simulation executions may complete before an HTTP request is created; successful simulated results are retained in the returned session and are immediately available from await_unary/2.

The process that calls start_unary/2 is the result owner. Cancellation may be requested from another BEAM process, but await_unary/2 must be called by the owner so terminal mailbox delivery remains deterministic.

unary(request, opts \\ [])