Geolix v1.1.0 Geolix View Source
IP location lookup provider.
Usage
Fetching information for a single IP is done by passing it as a binary or
tuple to Geolix.lookup/1
:
iex> Geolix.lookup("127.0.0.1")
%{
city: %{...},
country: %{...}
}
The response will be a map with the :id
of each configured database as the
key and the database response as the value.
If you are only interested in the response of a specific database you can use
Geolix.lookup/2
:
iex> Geolix.lookup({127, 0, 0, 1}, where: :my_database)
%{...}
The result structured of each database is specific to the adapter used.
Lookup Options
There are two options you can pass to Geolix.lookup/2
to modify the lookup
behaviour:
:timeout
- GenServer call timeout for the lookup. Defaults to5_000
.:where
- Lookup information in a single registered database
The adapter used can require and/or understand additional options. To accommodate this the options are passed unmodified to the adapter's on lookup function.
Link to this section Summary
Functions
Loads a database according to its specification.
Looks up IP information.
Fetch metadata from one or multiple databases.
Reloads all configured databases in the background.
Unloads a database.
Link to this section Functions
Loads a database according to its specification.
Requires at least the fields :id
and :adapter
. Any other required
fields depend on the adapter's requirements.
lookup(ip, opts \\ [])
View Sourcelookup(ip :: :inet.ip_address() | binary(), opts :: Keyword.t()) :: map() | nil
Looks up IP information.
Fetch metadata from one or multiple databases.
Reloads all configured databases in the background.
Unloads a database.
This operation is lazy. The database will stay loaded but won't be reloaded or used for lookups.