Geolix v1.1.0 Geolix.Adapter behaviour View Source

Adapter behaviour module.

Link to this section Summary

Callbacks

Returns the children to be supervised by Geolix.Database.Supervisor.

Loads a given database into Geolix.

Looks up IP information.

Returns metadata information for a database if available.

Unloads a given database from Geolix.

Link to this section Callbacks

Link to this callback

database_workers(database)

View Source (optional)
database_workers(database :: map()) :: [
  :supervisor.child_spec() | {module(), term()} | module()
]

Returns the children to be supervised by Geolix.Database.Supervisor.

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.

Link to this callback

load_database(database)

View Source (optional)
load_database(database :: map()) :: :ok | {: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.

Link to this callback

lookup(ip, opts, database)

View Source
lookup(ip :: :inet.ip_address(), opts :: Keyword.t(), database :: map()) ::
  map() | nil

Looks up IP information.

Link to this callback

metadata(database)

View Source (optional)
metadata(database :: map()) :: map() | nil

Returns metadata information for a database if available.

Link to this callback

unload_database(database)

View Source (optional)
unload_database(database :: map()) :: :ok

Unloads a given database from Geolix.