Onelastleaf.PluginSDK.Plugin (onelastleaf_plugin_sdk v0.1.0)

Copy Markdown View Source

Defines a plugin and runs its long-lived oll session.

Build a plugin with new!/2, register each action with action/4, then pass it to run!/1 from the escript entry point.

Summary

Functions

Registers an action handler.

Creates a plugin with its permanent ID and implementation version.

Runs the plugin until oll closes the session or the parent-liveness pipe.

Types

handler()

t()

@type t() :: %Onelastleaf.PluginSDK.Plugin{
  actions: %{required(String.t()) => {String.t(), handler()}},
  id: String.t(),
  version: String.t()
}

Functions

action(plugin, name, description, handler)

@spec action(t(), String.t(), String.t(), handler()) :: t()

Registers an action handler.

Action names must be unique, nonempty UTF-8 strings. A handler receives the per-job action context and ordered string arguments, and must return an Onelastleaf.PluginSDK.ActionResult.

new!(id, version)

@spec new!(String.t(), String.t()) :: t()

Creates a plugin with its permanent ID and implementation version.

The ID must be a valid dotted plugin ID such as "example.echo". The version is reported to oll and must be nonempty UTF-8.

run!(plugin)

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

Runs the plugin until oll closes the session or the parent-liveness pipe.

oll supplies the gRPC endpoint in OLL_PLUGIN_ENDPOINT. This function blocks for the lifetime of the process and raises on setup or protocol failures. It returns :ok after a graceful oll shutdown.