Ltix.Deployable protocol (Ltix v0.2.0)

Copy Markdown View Source

Protocol for converting your deployment struct to an Ltix.Deployment.

Implement it for your deployment struct, and your storage adapter can return that struct. The Ltix.LaunchContext from a launch has your struct.

defmodule MyApp.ToolDeployment do
  defstruct [:id, :registration_id, :deployment_id, :label]

  defimpl Ltix.Deployable do
    def to_deployment(dep) do
      Ltix.Deployment.new(dep.deployment_id)
    end
  end
end

Ltix.Deployment implements this protocol, so your storage adapter can also return a %Deployment{}. Login and launch return the same error as Ltix.Deployment.new/1 for an invalid one.

Summary

Types

t()

All the types that implement this protocol.

Functions

Return the Ltix.Deployment for the given struct.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

to_deployment(source)

@spec to_deployment(t()) :: {:ok, Ltix.Deployment.t()} | {:error, Exception.t()}

Return the Ltix.Deployment for the given struct.

Build it with Ltix.Deployment.new/1, which validates the fields.