ex_api v1.0.0-rc.2 ExApi View Source

This module manages all apis and theirs implementations.

Link to this section Summary

Functions

Lists all registered apis

Checks given api

Checks implementation

Fetches api

Fetches default implementation for specified api

Fetches fallback implementation for specified api

Check support of feature for specific implementation

Check support of feature for specific api and implementation

Fetches implementation

Fetches implementation for specified group and api

Fetches all implementations for specified api

Returns server state

Callback implementation of: GenServer.init/1

Registers api asynchronously

Registers api fallback implementation asynchronously

Registers api implementation asynchronously

Registers api implementation asynchronously

Changes default api implementation asynchronously

Changes default api implementation asynchronously

Starts ExApi server

Stops ExApi and all apis servers

Unregisters api asynchronously

Unregisters api fallback asynchronously

Unregisters api implementation asynchronously

Unregisters api implementation asynchronously

Link to this section Functions

Lists all registered apis.

Checks given api

Checks implementation with api.

Link to this function get_default_impl(api_or_module) View Source
get_default_impl(ExApi.Api.t) ::
  {:ok, ExApi.Implementation.t | nil} |
  {:error, ExApi.Error.ApiMismatchError.t} |
  {:error, ExApi.Error.ApiNotRegisteredError.t}
get_default_impl(module) ::
  {:ok, ExApi.Implementation.t | nil} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}

Fetches default implementation for specified api.

Link to this function get_fallback_impl(api_or_module) View Source
get_fallback_impl(ExApi.Api.t) ::
  {:ok, ExApi.Implementation.t | nil} |
  {:error, ExApi.Error.ApiMismatchError.t} |
  {:error, ExApi.Error.ApiNotRegisteredError.t}
get_fallback_impl(module) ::
  {:ok, ExApi.Implementation.t | nil} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}

Fetches fallback implementation for specified api.

Link to this function get_feature_support(impl_or_module, feature) View Source
get_feature_support(ExApi.Implementation.t, {name :: atom, arity :: non_neg_integer}) ::
  {:ok, Feature.support} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.FeatureNotFoundError.t} |
  {:error, ExApi.Error.ImplementationNotFoundError.t}
get_feature_support(module, {name :: atom, arity :: non_neg_integer}) ::
  {:ok, Feature.support} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.FeatureNotFoundError.t} |
  {:error, ExApi.Error.ImplementationNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotImplementationError.t}

Check support of feature for specific implementation.

Link to this function get_feature_support(api_or_module, impl_or_id_or_group_with_id, feature) View Source
get_feature_support(ExApi.Api.t, ExApi.Implementation.t, {name :: atom, arity :: non_neg_integer}) ::
  {:ok, Feature.support} |
  {:error, ExApi.Error.ApiMismatchError.t} |
  {:error, ExApi.Error.ApiNotRegisteredError.t} |
  {:error, ExApi.Error.FeatureNotFoundError.t} |
  {:error, ExApi.Error.ImplementationMismatchError.t} |
  {:error, ExApi.Error.ImplementationNotRegisteredError.t} |
  {:error, ExApi.Error.WrongApiError.t}
get_feature_support(ExApi.Api.t, {group :: atom, id :: atom} | id :: atom, {name :: atom, arity :: non_neg_integer}) ::
  {:ok, Feature.support} |
  {:error, ExApi.Error.ApiMismatchError.t} |
  {:error, ExApi.Error.ApiNotRegisteredError.t} |
  {:error, ExApi.Error.FeatureNotFoundError.t} |
  {:error, ExApi.Error.ImplementationNotFoundError.t}
get_feature_support(module, ExApi.Implementation.t, {name :: atom, arity :: non_neg_integer}) ::
  {:ok, Feature.support} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.FeatureNotFoundError.t} |
  {:error, ExApi.Error.ImplementationMismatchError.t} |
  {:error, ExApi.Error.ImplementationNotRegisteredError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}
get_feature_support(module, {group :: atom, id :: atom} | id :: atom, {name :: atom, arity :: non_neg_integer}) ::
  {:ok, Feature.support} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.FeatureNotFoundError.t} |
  {:error, ExApi.Error.ImplementationNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}

Check support of feature for specific api and implementation.

Fetches all implementations for specified api.

Link to this function get_state() View Source
get_state() :: {:ok, %{optional(module) => ExApi.Api.t}}

Returns server state

Link to this function init(args) View Source
init(args :: term) ::
  {:ok, state} |
  {:ok, state, timeout | :hibernate} |
  :ignore |
  {:stop, reason :: any} when state: any

Callback implementation of: GenServer.init/1.

Link to this function register_api(api_or_module) View Source
register_api(ExApi.Api.t | module) ::
  {:ok, pid} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}

Registers api asynchronously.

Link to this function register_fallback_impl(impl_or_module) View Source
register_fallback_impl(ExApi.Implementation.t) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.NotApiError.t}
register_fallback_impl(module) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t} |
  {:error, ExApi.Error.NotImplementationError.t}

Registers api fallback implementation asynchronously.

Link to this function register_impl(impl_or_module) View Source
register_impl(ExApi.Implementation.t) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.NotApiError.t}
register_impl(module) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t} |
  {:error, ExApi.Error.NotImplementationError.t}

Registers api implementation asynchronously.

Link to this function register_impl(impl_or_module, group) View Source
register_impl(ExApi.Implementation.t | module, atom) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t} |
  {:error, ExApi.Error.NotImplementationError.t}

Registers api implementation asynchronously.

Link to this function set_default_impl(impl_or_module) View Source

Changes default api implementation asynchronously.

Link to this function set_default_impl(api_or_module, impl_or_id_or_group_with_id) View Source
set_default_impl(ExApi.Api.t, ExApi.Implementation.t) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiMismatchError.t} |
  {:error, ExApi.Error.ApiNotRegisteredError.t} |
  {:error, ExApi.Error.ImplementationMismatchError.t} |
  {:error, ExApi.Error.ImplementationNotRegisteredError.t} |
  {:error, ExApi.Error.WrongApiError.t}
set_default_impl(ExApi.Api.t, {group :: atom, id :: atom} | id :: atom) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiMismatchError.t} |
  {:error, ExApi.Error.ApiNotRegisteredError.t} |
  {:error, ExApi.Error.ImplementationNotFoundError.t}
set_default_impl(module, ExApi.Implementation.t) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ImplementationMismatchError.t} |
  {:error, ExApi.Error.ImplementationNotRegisteredError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}
set_default_impl(module, {group :: atom, id :: atom} | id :: atom) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ImplementationNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}

Changes default api implementation asynchronously.

Link to this function start_link(args \\ []) View Source
start_link([]) :: GenServer.on_start

Starts ExApi server.

Stops ExApi and all apis servers.

Link to this function unregister_api(api_or_module) View Source
unregister_api(ExApi.Api.t) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiMismatchError.t} |
  {:error, ExApi.Error.ApiNotRegisteredError.t}
unregister_api(module) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}

Unregisters api asynchronously.

Link to this function unregister_fallback_impl(api_or_module) View Source
unregister_fallback_impl(ExApi.Api.t) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiMismatchError.t} |
  {:error, ExApi.Error.ApiNotRegisteredError.t}
unregister_fallback_impl(module) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotApiError.t}

Unregisters api fallback asynchronously.

Unregisters api implementation asynchronously.

Link to this function unregister_impl(impl_or_module, group) View Source
unregister_impl(ExApi.Implementation.t, atom) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ImplementationNotFoundError.t}
unregister_impl(module, atom) ::
  {:ok, pid} |
  {:error, ExApi.Error.ApiNotFoundError.t} |
  {:error, ExApi.Error.ImplementationNotFoundError.t} |
  {:error, ExApi.Error.ModuleNotLoadedError.t} |
  {:error, ExApi.Error.NotImplementationError.t}

Unregisters api implementation asynchronously.