FlamePeer (FlamePeer v1.0.1)

Copy Markdown View Source

FlamePeer provides a FLAME backend for Erlang :peer nodes.

How Does It Work?

FlamePeer uses Erlang's :peer module in order to create :peer nodes. This backend can be used to mimic a realistic FLAME cluster with real, isolated nodes that run on the local machine. It should generally be reserved for running in test and development environments to fully mimic the FLAME experience while staying fully local.

Usage

To use, you must tell FLAME to use the FlamePeer backend by default. This can be set via application configuration in your config/dev.exs and config/test.exs:

config :flame, :backend, FlamePeer

Required Configurations

  • :app - The name of your application. Defaults to System.get_env("RELEASE_NAME") in a release. However, since this backend is typically used in development and testing environments, it must be set on the configuration.

Optional Configurations

  • :boot_timeout - A timeout for booting a new node. Defaults to 30_000 (30 seconds).

  • :peer_applications - A list of peer applications to enforce starting on the peer node. Erlang :peer nodes don't automatically start any applications on startup, so this configuration defines which applications should be initialized on startup. Defaults to the :app value. If your application needs other applications to start up automatically, they must be specified in this option. The :flame and :flame_peer applications are automatically enforced to be in this list, to ensure that the necessary processes for FLAME and FlamePeer are properly started at all times.

Environment Variables

:peer nodes do not inherit the environment variables of the parent. You must explicit provide the environment that you would like to forward to the machine. For example, if your FLAME's are starting your Ecto repos, you can copy the env from the parent:

config :flame, FlamePeer,
  env: %{
    "DATABASE_URL" => System.fetch_env!("DATABASE_URL"),
    "POOL_SIZE" => "1"
  }

Or pass the env to each pool:

{FLAME.Pool,
  name: MyRunner,
  backend: {FlamePeer, env: %{"DATABASE_URL" => System.fetch_env!("DATABASE_URL")}}
}