Forex.Fetcher (Forex v1.1.2)

Copy Markdown View Source

The Forex.Fetcher module is responsible for fetching the exchange rates from the cache or the feed on periodic intervals or on demand.

The exchange rates are fetched from the cache if the cache is enabled and the cache is not stale. Otherwise, the exchange rates are fetched from the feed and stored in the cache.

By default, the exchange rates are fetched from the feed every 12 hours as the European Central Bank (ECB) updates the reference rates at around 16:00 CET every working day. This can be configured by setting the :schedular_interval option in the Forex application environment or by passing it as an option when starting the Forex.Fetcher process.

Summary

Functions

Returns a specification to start this module under a supervisor.

Fetch the respective exchange rates from the cache or the feed, based on the key and the opts.

Get the options used to start the Forex.Fetcher process.

Returns the default options for the Forex.Fetcher process.

Start the Forex.Fetcher process with the given options.

Start the Forex.Fetcher process linked to the current process with the given options.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get(key, opts \\ Options.fetcher_options())

Fetch the respective exchange rates from the cache or the feed, based on the key and the opts.

The key can be one of the following atoms:

  • :latest_rates - Fetch the latest exchange rates.
  • :last_ninety_days_rates - Fetch the exchange rates for the last 90 days.
  • :historic_rates - Fetch the exchange rates for a specific date.

Options

  • :use_cache (boolean/0) - Whether to use cached rates The default value is true.

  • :feed_fn - Optional custom feed function as {module, function, args}

  • :schedular_interval (integer/0) - Interval for the scheduler to fetch rates The default value is 43200000.

get_options(server \\ __MODULE__)

Get the options used to start the Forex.Fetcher process.

options()

Returns the default options for the Forex.Fetcher process.

start(opts \\ Options.fetcher_options())

Start the Forex.Fetcher process with the given options.

Options

  • :use_cache (boolean/0) - Whether to use cached rates The default value is true.

  • :feed_fn - Optional custom feed function as {module, function, args}

  • :schedular_interval (integer/0) - Interval for the scheduler to fetch rates The default value is 43200000.

start_link(opts \\ Options.fetcher_options())

Start the Forex.Fetcher process linked to the current process with the given options.

Options

  • :use_cache (boolean/0) - Whether to use cached rates The default value is true.

  • :feed_fn - Optional custom feed function as {module, function, args}

  • :schedular_interval (integer/0) - Interval for the scheduler to fetch rates The default value is 43200000.