View Source Geocoder.Config (geocoder v2.2.1)

Centralization of configurations and defaults values.

The following options are available for configuration.

  • :pool_name - The name for the pool.
  • :pool_config - The configuration for the pool. It uses Poolboy behind the scene, so the following configuration key exists.
  • :store_module - The store module to use. Defaults to Geocoder.Store
  • :store_config - The store configuration
  • :worker_config - The worker configuration. Things like the provider, key, or even custom JSON codec or HTTP clients

Here is full example of a configuration (with all the defaults)

[
  pool_name: :geocoder_workers,
  pool_config: [
    worker_module: Geocoder.Worker,
    size: 4,
    max_overflow: 2,
    strategy: :lifo,
    name: {:local, :geocoder_workers}
  ],
  store_module: Geocoder.Store,
  store_config: [name: :geocoder_store, precision: 6],
  worker_config: [
    provider: Geocoder.Providers.OpenStreetMaps,
    key: nil,
    http_client: Geocoder.HttpClient.Httpoison,
    http_client_opts: [recv_timeout: 30000],
    json_codec: Jason,
    data: nil
  ]
]

Summary

Types

geocoder_config()

@type geocoder_config() :: [geocoder_option()]

geocoder_option()

@type geocoder_option() ::
  {:pool_name, atom()}
  | {:pool_config, pool_config()}
  | {:store_module, module()}
  | {:store_config, store_config()}
  | {:worker_config, worker_config()}

pool_config()

@type pool_config() :: [pool_option()]

pool_option()

@type pool_option() ::
  {:worker_module, module()}
  | {:size, pos_integer()}
  | {:max_overflow, pos_integer()}
  | {:strategy, :fifo | :lifo}
  | {:name, atom() | {atom(), atom()}}

store_config()

@type store_config() :: [store_option()]

store_option()

@type store_option() :: {:name, atom()} | {:precision, pos_integer()}

worker_config()

@type worker_config() :: [worker_option()]

worker_option()

@type worker_option() ::
  {:provider, module()}
  | {:key, binary()}
  | {:http_client, module()}
  | {:http_client_opts, keyword()}
  | {:json_codec, module()}
  | {:data, map()}

Functions

all(opts \\ [])

@spec all(geocoder_config()) :: geocoder_config()

default_pool_name()

@spec default_pool_name() :: :geocoder_workers

default_store_name()

@spec default_store_name() :: :geocoder_store

pool_config(opts \\ [])

@spec pool_config(geocoder_config()) :: pool_config()

pool_name(opts \\ [])

@spec pool_name(geocoder_config()) :: atom()

store_config(opts \\ [])

store_module(opts \\ [])

@spec store_module(geocoder_config()) :: atom()

worker_config(opts \\ [])

@spec worker_config(geocoder_config()) :: worker_config()
@spec worker_config(geocoder_config()) :: store_config()