Bedrock.Service.Manifest (bedrock v0.5.2)

View Source

Service manifest utilities for worker specifications and metadata.

Summary

Types

t()

@type t() :: %Bedrock.Service.Manifest{
  cluster: Bedrock.Cluster.name(),
  id: String.t(),
  params: %{required(atom()) => term()},
  worker: module()
}

Functions

load_from_file(path_to_manifest)

@spec load_from_file(path_to_manifest :: Path.t()) ::
  {:ok, t()}
  | {:error,
     :manifest_does_not_exist
     | :manifest_is_invalid
     | :manifest_is_not_a_dictionary
     | :worker_module_is_invalid
     | :worker_module_does_not_exist
     | :worker_module_failed_to_load
     | :invalid_cluster_id
     | :invalid_cluster_name
     | :invalid_worker_name
     | :worker_module_does_not_implement_behaviour
     | :invalid_params
     | {:file_read_error, atom()}}

new(cluster, id, worker, params \\ %{})

@spec new(
  Bedrock.Cluster.name(),
  id :: Bedrock.service_id(),
  worker :: module(),
  params :: %{required(atom()) => term()}
) :: t()

params_from_json(params)

@spec params_from_json(map() | nil | term()) ::
  {:ok, map()} | {:error, :invalid_params}

write_to_file(manifest, path_to_manifest)

@spec write_to_file(manifest :: t(), path_to_manifest :: Path.t()) ::
  :ok | {:error, File.posix()}