Cyclium.Tool behaviour (Cyclium v0.1.10)

Copy Markdown View Source

Behaviour for tool implementations. Tools are provided by the consuming app and wrapped by ToolExec.

Minimal implementation

defmodule MyApp.Tools.ERP do
  use Cyclium.Tool

  def call(:read_po, args, _ctx), do: {:ok, fetch_po(args["po_id"])}
end

use Cyclium.Tool provides sensible defaults for all optional callbacks. Override any of them as needed.

Summary

Callbacks

cache_scope(args)

@callback cache_scope(args :: map()) :: binary()

cache_ttl()

@callback cache_ttl() :: non_neg_integer() | :no_cache

call(action, args, ctx)

@callback call(action :: atom(), args :: map(), ctx :: map()) ::
  {:ok, result :: term()} | {:error, reason :: term()}

redact(args)

@callback redact(args :: map()) :: map()

redact_result(result)

@callback redact_result(result :: term()) :: term()

side_effect?()

@callback side_effect?() :: boolean()