Geolix.Adapter behaviour (Geolix v2.1.0)

View Source

Adapter behaviour module.

Summary

Callbacks

Returns the adapter processes to be supervised.

Loads a given database into Geolix.

Looks up IP information.

Returns metadata information for a database if available.

Unloads a given database from Geolix.

Callbacks

database_workers(database)

(optional)
@callback database_workers(database :: Geolix.database()) :: [
  :supervisor.child_spec() | {module(), term()} | module()
]

Returns the adapter processes to be supervised.

If no automatic supervision should take place or it is intended to use an adapter specific supervisor (e.g. using the application config) this callback should be either unimplemented or return an empty list.

load_database(database)

(optional)
@callback load_database(database :: Geolix.database()) ::
  :ok | :delayed | {:error, term()}

Loads a given database into Geolix.

Requires at least the fields :id and :adapter. Any other required fields depend on the adapter's requirements.

lookup(ip, opts, database)

@callback lookup(
  ip :: :inet.ip_address(),
  opts :: Keyword.t(),
  database :: Geolix.database()
) ::
  map() | nil

Looks up IP information.

metadata(database)

(optional)
@callback metadata(database :: Geolix.database()) :: map() | nil

Returns metadata information for a database if available.

unload_database(database)

(optional)
@callback unload_database(database :: Geolix.database()) :: :ok

Unloads a given database from Geolix.