LiveLoad.Browser (LiveLoad v0.0.1-rc.28)

Copy Markdown View Source

LiveLoad.Browser is the struct representing the browser abstraction that is used in a LiveLoad.Scenario. It wraps the given implementation of the LiveLoad.Browser.Connection behaviour. All operations on the browser instance are delegated to the LiveLoad.Browser.Connection implementation.

LiveLoad.Browser is the top-level of the Browser hierarchy. For every node running a LiveLoad.Scenario, a single LiveLoad.Browser is created, and each user receives a clean, isolated LiveLoad.Browser.Context created via LiveLoad.Browser.new_context/1.

For operations users can take on the context, see the LiveLoad.Browser.Context module.

Summary

Functions

Delegates to the connection implementation on the browser and runs the LiveLoad.Browser.Connection.drain_metrics/1 callback found on the implementation.

Delegates to the connection implementation on the browser and runs the LiveLoad.Browser.Connection.new_context/1 callback found on the implementation.

Set a value on the private field on the browser struct. This is useful for Connection implementations to add private data that they need access to while running.

Starts up a supervision tree for a browser that can be used to control a browser instance. The connection_mod must be a module implementing the LiveLoad.Browser.Connection behaviour. Any opts passed in are forwarded to the connection module.

Stops the browser instance by stopping the current browser's supervision tree.

Types

t()

@type t() :: %LiveLoad.Browser{
  connection:
    {LiveLoad.Browser.Connection.t(), LiveLoad.Browser.Connection.opts()},
  private: %{optional(atom()) => term()},
  supervisor_pid: pid()
}

Functions

drain_metrics(browser)

@spec drain_metrics(browser :: t()) :: :ok

Delegates to the connection implementation on the browser and runs the LiveLoad.Browser.Connection.drain_metrics/1 callback found on the implementation.

new_context(browser)

@spec new_context(browser :: t()) ::
  {:ok, LiveLoad.Browser.Context.t()} | {:error, term()}

Delegates to the connection implementation on the browser and runs the LiveLoad.Browser.Connection.new_context/1 callback found on the implementation.

put_private(browser, key, value)

@spec put_private(browser :: t(), key :: atom(), value :: term()) :: t()

Set a value on the private field on the browser struct. This is useful for Connection implementations to add private data that they need access to while running.

start_link(connection_mod, opts \\ [])

@spec start_link(
  connection_mod :: LiveLoad.Browser.Connection.t(),
  opts :: Keyword.t()
) ::
  {:ok, t()} | {:error, term()}

Starts up a supervision tree for a browser that can be used to control a browser instance. The connection_mod must be a module implementing the LiveLoad.Browser.Connection behaviour. Any opts passed in are forwarded to the connection module.

Before starting, the LiveLoad.Browser.Connection.before_start/1 hook is called. After starting, the LiveLoad.Browser.Connection.after_start/1 hook is called.

stop(browser, reason \\ :normal, timeout \\ :infinity)

@spec stop(browser :: t(), reason :: term(), timeout :: timeout()) :: :ok

Stops the browser instance by stopping the current browser's supervision tree.

Before stopping, the LiveLoad.Browser.Connection.before_stop/1 hook is called. After stopping, the LiveLoad.Browser.Connection.after_stop/1 hook is called.