Onelastleaf.PluginSDK.ActionContext (onelastleaf_plugin_sdk v0.1.0)

Copy Markdown View Source

Per-job access to cancellation state and oll host capabilities.

The SDK supplies a context to every action handler. Do not construct or retain it after the handler finishes. Host calls and artifact transfers are scoped to the current job and may raise if the job is cancelled or its deadline expires.

Summary

Functions

Returns whether oll has requested cancellation of the current job.

Raises if oll has requested cancellation of the current job.

Reads configuration at path.

Performs a raw oll host call.

Invokes a configuration function with protobuf configuration values.

Writes a structured log record through oll.

Stores an artifact through oll.

Types

t()

@opaque t()

Functions

cancelled?(action_context)

@spec cancelled?(t()) :: boolean()

Returns whether oll has requested cancellation of the current job.

check_cancellation!(action_context)

@spec check_cancellation!(t()) :: :ok

Raises if oll has requested cancellation of the current job.

get_config(context, path \\ nil)

@spec get_config(t(), Oll.Protocol.ConfigPath.t() | nil) ::
  {:ok, Oll.Protocol.GetConfigResponse.t()} | {:error, term()}

Reads configuration at path.

Passing nil reads the root. On success the returned protobuf response contains the requested value.

host_call(context, request)

@spec host_call(
  t(),
  {atom(), struct()}
) :: {:ok, Oll.Protocol.HostCallResponse.t()} | {:error, term()}

Performs a raw oll host call.

request is a {variant, protobuf_request} tuple accepted by the Oll.Protocol.HostCallRequest.call oneof. Prefer a specialized helper when one is available.

invoke_config_function(context, function, arguments)

@spec invoke_config_function(
  t(),
  Oll.Protocol.ConfigFunctionRef.t(),
  [Oll.Protocol.ConfigValue.t()]
) :: {:ok, Oll.Protocol.InvokeConfigFunctionResponse.t()} | {:error, term()}

Invokes a configuration function with protobuf configuration values.

log(context, level, target, message, fields \\ %{})

@spec log(t(), Oll.Protocol.LogLevel.t(), String.t(), String.t(), map()) ::
  :ok | {:error, term()}

Writes a structured log record through oll.

Field values must be serializable protobuf configuration values. Function references are not serializable and are rejected.

store_artifact(context, artifact, chunks)

@spec store_artifact(t(), Oll.Protocol.ArtifactDescriptor.t(), Enumerable.t()) ::
  {:ok, Oll.Protocol.ArtifactStored.t()}

Stores an artifact through oll.

chunks is consumed once and spooled while its size and SHA-256 digest are checked against artifact. Every chunk must be a nonempty binary no larger than the limit negotiated with oll. Include the descriptor in the terminal result with Onelastleaf.PluginSDK.ActionResult.with_artifacts/2 only after this function returns successfully.