# BatchElixir

Send transactional notifications to Batch

## Installation

If [available in Hex](, the package can be installed
by adding `batch_elixir` to your list of dependencies in `mix.exs`:

def deps do
    {:batch_elixir, "~> 0.2.0"}

def application do
    applications: [:batch_elixir]

## Configuration

config :batch_elixir,
  rest_api_key: "rest api key", # Required, if not provided the application fail to start
  devices: "your rest api key of batch", # required
  default_deeplink: "myapp://" # required,
  producer_name: BatchElixir.Server.Producer, # name of the producer. By default the producer is BatchElixir.Server.Producer
  consumer_options: [], # extra options for GenStage as consumer. Typically [min_demand:10, max_demand: 100]
  producer_options: [], # extra options for GenStage as producer. Typically [buffer_size: 10_000]
  batch_url: "", # Base url of batch api
  retry_interval_in_milliseconds: 1_000, # Interval between each failed requests
  max_attempts: 3, # Maximum attempts of failed requests
  number_of_consumers: 1, # Number of consumers to pop. By default is 1
  stats_driver: BatchElixir.Stats.Memory # BatchElixir.Stats.Memory For In memory stats or BatchElixir.Stats.Statix to send to datadog via Statix

Documentation can be generated with [ExDoc](
and published on [HexDocs]( Once published, the docs can
be found at [](

## Behaviour testing

For behaviour test please refers to [](./behaviour_test/

## Stress test

If you want a stub for batch check [](./stub_batch/

To run the test

mix benchmark --config stress_test/config.json [--observer] --max number_of_consumers  number_of_notification number_of_iterations

* `--config`: configuration file
* `--observer`: Launche the observer window
* `number_of_consumers`: Numer of consumers.
* `number_of_notification`: Numer of notifications to send.
* `number_of_iterations`: Numer of iterations to run.

You also have bash script that will run 1, 10, 100, 1000, 10000, 1000000 notifications with 10, 100, 1000 consumers each.

./ [--observer]

Warns and errors will be outputed to the file: `stress_test.log`