From 6eb0dec5ed1c9bf6b38d4a080ce5bb26a67dc728 Mon Sep 17 00:00:00 2001 From: Petrus Janse van Rensburg Date: Wed, 10 Jul 2024 08:23:36 -0700 Subject: [PATCH 1/2] Update README.md Fix reference to MaxMind license key section. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfadb40..75e19b4 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ MaxMind.* Get a free [license key](https://www.maxmind.com/en/geolite2/signup) from MaxMind if you haven't one already. Once logged in, you'll find the -page to generate it on the left menu, under "My License Key". +page to generate it on the left menu, under "Manage License Keys". Then clone the repository, run `make shell` and declare your key: From 9e3097f1d5622f3aba77f6fc7846e338d3fd1607 Mon Sep 17 00:00:00 2001 From: "P.J. Janse van Rensburg" Date: Wed, 10 Jul 2024 08:56:43 -0700 Subject: [PATCH 2/2] add setup instructions for usage from an Elixir app --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 75e19b4..85c570f 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,24 @@ Then clone the repository, run `make shell` and declare your key: application:set_env(locus, license_key, "YOUR_LICENSE_KEY"). ``` +If you're using Elixir, add locus as a dependency to your mix project: + +```elixir +defp deps do + [ + ... + {:locus, "~> 2.3"} + ] + end +``` + +Then, configure your license key in `config.exs`: + +```elixir +config :locus, + license_key: +``` + #### 2\. Start the database loader ``` erlang @@ -47,6 +65,17 @@ ok = locus:start_loader(country, {maxmind, "GeoLite2-Country"}). % implementing the locus_custom_fetcher behaviour. ``` +Or, in Elixir, start the database loaders that you'll be using in `application.ex`: + +```elixir + def start(_type, _args) do + # :locus.start_loader(:asn, {:maxmind, "GeoLite2-ASN"}) + # :locus.start_loader(:country, {:maxmind, "GeoLite2-Country"}) + :locus.start_loader(:city, {:maxmind, "GeoLite2-City"}) + + ... +``` + #### 3\. Wait for the database to load (optional) ``` erlang @@ -102,6 +131,17 @@ ok = locus:start_loader(country, {maxmind, "GeoLite2-Country"}). <<"zh-CN">> => <<"美国"/utf8>>}}}} ``` +Or, in Elixir, call the erlang library from your Elixir application: + +```elixir +iex> :locus.lookup(:city, "93.184.216.34") +{:ok, + %{ + "city" => %{"geoname_id" => 4945936, "names" => %{"en" => "Norwell"}}, + ... + }} +``` + ## Documentation 1. [Supported File Formats](#supported-file-formats)