Skip to content

Using remote database source results in time out when app first starts #20

@mcade

Description

@mcade

When I config the database source as a link to a remote file I can't use the Geolix.lookup/2 function until the database has been loaded from the remote source.

How can I check if the remote geoip database has been loaded before I run any functions like Geolix.lookup/2?

This is my current config:

config :geolix,
  databases: [
    %{
      id: :city,
      adapter: Geolix.Adapter.MMDB2,
      source: "https://example.com/geoip/GeoLite2-City.mmdb"
    },
    %{
      id: :country,
      adapter: Geolix.Adapter.MMDB2,
      source: "https://example.com/geoip/GeoLite2-Country.mmdb"
    }
  ]

And the timeout error message:

[error] GenServer #PID<0.603.0> terminating
** (stop) exited in: GenServer.call(Geolix.Database.Loader, :loaded, 5000)
    ** (EXIT) time out
    (elixir) lib/gen_server.ex:834: GenServer.call/3
    (geolix) lib/geolix/server/worker.ex:26: Geolix.Server.Worker.lookup_all/2
    (geolix) lib/geolix/server/worker.ex:20: Geolix.Server.Worker.handle_call/3
    (stdlib) gen_server.erl:636: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:665: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.604.0>): {:lookup, '127, 0, 0, 1', [as: :struct, locale: :en, where: nil]}

The readme mentions: "Note: Please be aware of the drawbacks of remote files! You should take into account the startup times as the file will be requested during GenServer.init/1. Unstable or slow networks could result in nasty timeouts." When I start my app however I don't experience any extra startup time. I'm using Elixir 1.6 and phoenix 1.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions