View Source Geocoder.Config (geocoder v2.0.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

@type geocoder_config() :: [geocoder_option()]
@type geocoder_option() ::
  {:pool_name, atom()}
  | {:pool_config, pool_config()}
  | {:store_module, module()}
  | {:store_config, store_config()}
  | {:worker_config, worker_config()}
@type pool_config() :: [pool_option()]
@type pool_option() ::
  {:worker_module, module()}
  | {:size, pos_integer()}
  | {:max_overflow, pos_integer()}
  | {:strategy, :fifo | :lifo}
  | {:name, atom() | {atom(), atom()}}
@type store_config() :: [store_option()]
@type store_option() :: {:name, atom()} | {:precision, pos_integer()}
@type worker_config() :: [worker_option()]
@type worker_option() ::
  {:provider, module()}
  | {:key, binary()}
  | {:http_client, module()}
  | {:http_client_opts, keyword()}
  | {:json_codec, module()}
  | {:data, map()}

Functions

@spec all(geocoder_config()) :: geocoder_config()
@spec default_pool_name() :: :geocoder_workers
@spec default_store_name() :: :geocoder_store
@spec pool_config(geocoder_config()) :: pool_config()
@spec pool_name(geocoder_config()) :: atom()
Link to this function

store_config(opts \\ [])

View Source
Link to this function

store_module(opts \\ [])

View Source
@spec store_module(geocoder_config()) :: atom()
Link to this function

worker_config(opts \\ [])

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