View Source LocationSimulator (LocationSimulator v0.7.0)
This is main api of library.
To start simple call iex> LocationSimulator.start()
Or start with your config iex> config = LocationSimulator.default_config() iex> config = Map.put(config, :worker, 1) iex> LocationSimulator.start(config)
Link to this section Summary
Functions
Get default config of library.
Start with default config.
Start with config.
Stop all workers.
Link to this section Functions
@spec default_config() :: map()
Get default config of library.
@spec start() :: :ok
Start with default config.
In this case, library just uses Logger to log data in every event. Remember start with default has no id then we can't stop worker by id.
@spec start(%{:worker => non_neg_integer(), optional(any()) => any()}) :: :ok
Start with config.
The config is a map type.
Config has info like:
%{
group_id: "group_id", # group id for workers, default is nil, using for stop all workers in a group.
worker: 3, # number of worker will run
event: 100, # number of GPS events will be trigger for a worker
interval: 1000, # this & random_range used for sleep between GPS events, if value is :infinity worker will run forever (you still stop by return {:stop, reason})
random_range: 0, # 0 mean no random, other positive will be used for generate extra random sleep time
callback: MyCallbackModule # your module will handle data
}
:id is reserved for worker's id. :group_id if added will be used for stop all workers in a group.
If you need pass your data to callback module you can add that in the config.
The config can be change after every event.
@spec stop(group_id :: any()) :: :ok
Stop all workers.
For using this function, you need to start with group_id options in config.