GoodAnalytics.Geo.Provider behaviour (GoodAnalytics v0.1.1)

Copy Markdown View Source

Behaviour for GeoIP providers.

An implementation receives a parsed IP address (:inet.ip_address/0 tuple) and returns either {:ok, raw_map} (provider-specific shape) or {:error, reason}. Raw output is passed to a GoodAnalytics.Geo.Normalizer which maps it to the canonical field set returned by GoodAnalytics.Geo.lookup/1.

The shipped implementation is GoodAnalytics.Geo.Locus.

Summary

Types

ip()

@type ip() :: :inet.ip_address()

raw_result()

@type raw_result() :: map()

reason()

@type reason() :: :not_found | :loader_not_ready | atom() | tuple()

Callbacks

lookup(ip)

@callback lookup(ip()) :: {:ok, raw_result()} | {:error, reason()}