LocationSimulator (LocationSimulator v1.1.0)

Copy Markdown View Source

Entry-point API for the LocationSimulator library.

defmodule MyApp.Tracker do
  use LocationSimulator.Pipeline

  source :synthetic, direction: :north, elevation: 50

  plug LocationSimulator.Plug.Callback, callback: MyApp.GpsHandler
end

LocationSimulator.start(MyApp.Tracker, %{worker: 3, event: 100, interval: 1_000})

With a plain config map (legacy)

LocationSimulator.start(%{
  worker:       3,
  event:        100,
  interval:     1_000,
  random_range: 200,
  direction:    :north,
  elevation:    50,
  callback:     MyApp.GpsHandler
})

Summary

Functions

Returns the merged default config (application config overrides built-in defaults).

Starts one worker with the default / application config.

Starts workers using a plain config map (legacy API).

Starts workers with a pipeline module and runtime config.

Stops all workers that belong to group_id.

Types

start_result()

@type start_result() :: :ok | {:error, term()}

Functions

default_config()

@spec default_config() :: map()

Returns the merged default config (application config overrides built-in defaults).

start()

@spec start() :: start_result()

Starts one worker with the default / application config.

start(config)

@spec start(map()) :: start_result()

Starts workers using a plain config map (legacy API).

See the module doc for supported config keys.

start(pipeline_mod, runtime_config)

@spec start(module(), map()) :: start_result()

Starts workers with a pipeline module and runtime config.

The pipeline module defines the GPS source and the plug chain. The config map supplies runtime parameters (worker count, event count, etc.).

Returns :ok, or {:error, reason} when a worker fails to start or the configured GPX glob matches no files.

stop(group_id)

@spec stop(group_id :: any()) :: :ok

Stops all workers that belong to group_id.