Outerfaces.Endpoints.DynamicLoader.DynamicLoaderBehavior behaviour (Outerfaces v0.2.3)

View Source

A behaviour module that outlines the required callbacks for DynamicLoader.

Summary

Callbacks

Creates the endpoint module for a project with a given outerfaces_project_name, app slug, and (dynamically generated) endpoint_module. Adds the built endpoint module to the given app web module, and adds the endpoint config to app config for the given app slug.

Returns a dynamic port number using the base port and index of the project * ports per project

Returns the endpoint config for the given arguments

Compiles and returns a list of the instantiated endpoint modules for each project.

Builds an endpoint module for a project for the given arguments.

Builds modules to define endpoints for each outerfaces project.

Callbacks

create_dynamic_endpoint_spec( project_name_with_index, otp_app_slug, app_web_module, project_base_port )

@callback create_dynamic_endpoint_spec(
  project_name_with_index :: {String.t(), non_neg_integer()},
  otp_app_slug :: atom(),
  app_web_module :: atom(),
  project_base_port :: pos_integer()
) :: {atom(), Keyword.t()}

Creates the endpoint module for a project with a given outerfaces_project_name, app slug, and (dynamically generated) endpoint_module. Adds the built endpoint module to the given app web module, and adds the endpoint config to app config for the given app slug.

dynamic_port(base_port, project_index)

@callback dynamic_port(
  base_port :: non_neg_integer(),
  project_index :: non_neg_integer()
) :: pos_integer()

Returns a dynamic port number using the base port and index of the project * ports per project

endpoint_config_for_project(project_name, dynamic_port, app_web_module)

@callback endpoint_config_for_project(
  project_name :: String.t(),
  dynamic_port :: pos_integer(),
  app_web_module :: atom()
) :: Keyword.t()

Returns the endpoint config for the given arguments

hydrate_endpoint_modules(project_directory_names, otp_app_slug, app_web_module, base_port)

@callback hydrate_endpoint_modules(
  project_directory_names :: [String.t()],
  otp_app_slug :: atom(),
  app_web_module :: atom(),
  base_port :: pos_integer()
) :: [{atom(), Keyword.t()}]

Compiles and returns a list of the instantiated endpoint modules for each project.

prepare_endpoint_module(outerfaces_project_name, otp_app_slug, built_endpoint_mdoule, opts)

@callback prepare_endpoint_module(
  outerfaces_project_name :: String.t(),
  otp_app_slug :: atom(),
  built_endpoint_mdoule :: atom(),
  opts :: Keyword.t() | nil
) :: :ok | no_return()

Builds an endpoint module for a project for the given arguments.

This allows developers to define custom endpoint plug pipelines for each project's endpoint.

prepare_endpoint_modules(project_directory_names, otp_app_slug, app_web_module, opts)

@callback prepare_endpoint_modules(
  project_directory_names :: [String.t()],
  otp_app_slug :: atom(),
  app_web_module :: atom(),
  opts :: Keyword.t() | nil
) :: :ok | {:error, String.t()}

Builds modules to define endpoints for each outerfaces project.