Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

More docs #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
2-part package for loading [GeoLite2 Database](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en) to redis and working with it from your application.

## app
Contains
Contains logic abot uploading existing GeoLite2 database to redis
## lib
Contains types + lookup function

Contains types + lookup functions

## Usage
1. login [here](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en)
Expand Down
15 changes: 10 additions & 5 deletions app/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import Prelude hiding (mapM, mapM_, take)

data Options = Options
{ redis :: ConnectInfo
, blockDb :: ByteString
, sortedSetName :: ByteString
, blocksFile :: FilePath
, locationFile :: FilePath
, ipv6 :: Bool
Expand All @@ -72,18 +72,23 @@ options =
connInfoReadM
( long "redis-conn"
<> short 'r'
<> help "Redis connection string like \"redis://user@localhost:6379/1\""
)
<*> strOption
( long "db-name"
( long "sorted-set"
<> short 'd'
<> help "Name for sorted set, where store data"
<> value "geoip_ipv4"
)
<*> strOption
( long "blocks-file"
<> short 'b'
<> help "Path to block data, like \"./GeoLite2-City-Blocks-IPv4.csv'\""
)
<*> strOption
( long "location-file"
<> short 'l'
<> help "Path to locations data, like \"./GeoLite2-City-Locations-ru.csv\""
)
<*> flag
False
Expand All @@ -99,7 +104,7 @@ main = do
{ redis
, blocksFile
, locationFile
, blockDb
, sortedSetName
, ipv6
} <-
execParser $
Expand Down Expand Up @@ -192,12 +197,12 @@ main = do
let records1 = [(fromIntegral lowerBorder :: Double, Store.encode $ fmap (Text.encodeUtf8) w) | w@GeoIPFull{lowerBorder} <- wibs]
liftIO . runRedis redisConn $
zaddOpts
blockDb
sortedSetName
(records1)
defaultZaddOpts{zaddCondition = Just Nx}
pure ()
)
Right c <- runRedis redisConn $ zcard blockDb
Right c <- runRedis redisConn $ zcard sortedSetName
c1 <- readIORef count
pPrint (c, c1)
pure ()
Expand Down