Portals.SDK behaviour (portals v0.1.0)

Copy Markdown View Source

The contract every portals_<language> package implements.

Core portals ships no worker SDKs. Each supported language lives in its own Hex package (portals_python, portals_ruby, portals_javascript, portals_php, portals_java, portals_go) that bundles its SDK under priv/ and exposes a module implementing this behaviour:

Every package also sets PORTALS_SDK_PATH in the worker's environment, as an escape hatch for scripts that need to locate the SDK themselves.

All packages are released in lockstep with portals, so a worker SDK always speaks the protocol version the BEAM expects.

Summary

Callbacks

Absolute path to the SDK bundled in this package's priv/ directory.

Expand language-specific options into Portals.start_worker/1 options.

Functions

The supported languages and the package that provides each one.

The Portals.SDK module for language, raising with installation instructions when its package is not a dependency of the current project.

Callbacks

sdk_path()

@callback sdk_path() :: Path.t()

Absolute path to the SDK bundled in this package's priv/ directory.

worker_opts(keyword)

@callback worker_opts(keyword()) :: keyword()

Expand language-specific options into Portals.start_worker/1 options.

Functions

languages()

@spec languages() :: %{required(String.t()) => {module(), atom()}}

The supported languages and the package that provides each one.

iex> Portals.SDK.languages()["python"]
{Portals.Python, :portals_python}

module!(language)

@spec module!(String.t()) :: module()

The Portals.SDK module for language, raising with installation instructions when its package is not a dependency of the current project.