toff63 / batch_elixir

Batch Elixir SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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"}
  ]
end
def application do
  [
    applications: [:batch_elixir]
  ]
end

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: "https://api.batch.com/1.1/", # 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 https://hexdocs.pm/batch_elixir.

Behaviour testing

For behaviour test please refers to README.md

Stress test

If you want a stub for batch check README.md.

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.

./stress_test.sh [--observer]

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

About

Batch Elixir SDK

License:MIT License


Languages

Language:Elixir 91.5%Language:JavaScript 3.0%Language:HTML 2.7%Language:Dockerfile 1.8%Language:Shell 1.0%