diff --git a/README.md b/README.md index 173d080..db1be53 100644 --- a/README.md +++ b/README.md @@ -64,22 +64,10 @@ result.ipLocation match { } ``` -`cats.Eval` and `cats.Id` are also supported: +`cats.Id` is also supported: ```scala -import cats.{Eval, Id} - -val evalResult: Eval[IpLookupResult] = for { - ipLookups <- CreateIpLookups[Eval].createFromFilenames( - geoFile = Some("/opt/maxmind/GeoLite2-City.mmdb") - ispFile = None, - domainFile = None, - connectionTypeFile = None, - memCache = false, - lruCacheSize = 20000 - ) - lookup <- ipLookups.performLookups("175.16.199.0") -} yield lookup +import cats.Id val idResult: IpLookupResult = { val ipLookups = CreateIpLookups[Id].createFromFilenames( diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 04cb9b1..b8b228b 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -16,7 +16,7 @@ object Dependencies { val maxmind = "com.maxmind.geoip2" % "geoip2" % "2.15.0" val catsEffect = "org.typelevel" %% "cats-effect" % "2.5.3" val cats = "org.typelevel" %% "cats-core" % "2.6.1" - val lruMap = "com.snowplowanalytics" %% "scala-lru-map" % "0.4.0" + val lruMap = "com.snowplowanalytics" %% "scala-lru-map" % "0.5.0" val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.14.3" % Test val specs2 = "org.specs2" %% "specs2-core" % "4.10.0" % Test } diff --git a/src/test/scala/com.snowplowanalytics.maxmind.iplookups/IpLookupsTest.scala b/src/test/scala/com.snowplowanalytics.maxmind.iplookups/IpLookupsTest.scala index d555081..a9bf04c 100644 --- a/src/test/scala/com.snowplowanalytics.maxmind.iplookups/IpLookupsTest.scala +++ b/src/test/scala/com.snowplowanalytics.maxmind.iplookups/IpLookupsTest.scala @@ -14,7 +14,7 @@ package com.snowplowanalytics.maxmind.iplookups import java.net.UnknownHostException -import cats.{Eval, Id} +import cats.Id import cats.effect.IO import cats.syntax.either._ import cats.syntax.option._ @@ -44,19 +44,6 @@ object IpLookupsTest { ) .unsafeRunSync() - def evalIpLookupsFromFiles(memCache: Boolean, lruCache: Int): IpLookups[Eval] = - CreateIpLookups[Eval] - .createFromFilenames( - Some(geoFile), - Some(ispFile), - Some(domainFile), - Some(connectionTypeFile), - Some(anonymousFile), - memCache, - lruCache - ) - .value - def idIpLookupsFromFiles(memCache: Boolean, lruCache: Int): IpLookups[Id] = CreateIpLookups[Id] .createFromFilenames( @@ -207,18 +194,15 @@ class IpLookupsTest extends Specification with Tables { lruCache <- Seq(0, 1000, 10000) } { - val ioIpLookups = ioIpLookupsFromFiles(memCache, lruCache) - val evalIpLookups = evalIpLookupsFromFiles(memCache, lruCache) - val idIpLookups = idIpLookupsFromFiles(memCache, lruCache) + val ioIpLookups = ioIpLookupsFromFiles(memCache, lruCache) + val idIpLookups = idIpLookupsFromFiles(memCache, lruCache) testData foreach { case (ip, expected) => formatter(ip, memCache, lruCache) should { - val ioActual = ioIpLookups.performLookups(ip).unsafeRunSync() - val evalActual = evalIpLookups.performLookups(ip).value - val idActual = idIpLookups.performLookups(ip) + val ioActual = ioIpLookups.performLookups(ip).unsafeRunSync() + val idActual = idIpLookups.performLookups(ip) matchIpLookupResult(ioActual, expected) - matchIpLookupResult(evalActual, expected) matchIpLookupResult(idActual, expected) } } @@ -226,9 +210,8 @@ class IpLookupsTest extends Specification with Tables { // If this test fails, see https://github.com/snowplow/scala-maxmind-iplookups/issues/96 "providing an invalid ip should fail" in { - val ioIpLookups = ioIpLookupsFromFiles(true, 0) - val evalIpLookups = evalIpLookupsFromFiles(true, 0) - val idIpLookups = idIpLookupsFromFiles(true, 0) + val ioIpLookups = ioIpLookupsFromFiles(true, 0) + val idIpLookups = idIpLookupsFromFiles(true, 0) val ioExpected = IpLookupResult( new UnknownHostException("not: Name or service not known").asLeft.some, new UnknownHostException("not: Name or service not known").asLeft.some, @@ -237,14 +220,6 @@ class IpLookupsTest extends Specification with Tables { new UnknownHostException("not: Name or service not known").asLeft.some, new UnknownHostException("not: Name or service not known").asLeft.some ) - val evalExpected = IpLookupResult( - new UnknownHostException("not").asLeft.some, - new UnknownHostException("not").asLeft.some, - new UnknownHostException("not").asLeft.some, - new UnknownHostException("not").asLeft.some, - new UnknownHostException("not").asLeft.some, - new UnknownHostException("not").asLeft.some - ) val idExpected = IpLookupResult( new UnknownHostException("not").asLeft.some, new UnknownHostException("not").asLeft.some, @@ -253,11 +228,9 @@ class IpLookupsTest extends Specification with Tables { new UnknownHostException("not").asLeft.some, new UnknownHostException("not").asLeft.some ) - val ioActual = ioIpLookups.performLookups("not").unsafeRunSync() - val evalActual = evalIpLookups.performLookups("not").value - val idActual = idIpLookups.performLookups("not") + val ioActual = ioIpLookups.performLookups("not").unsafeRunSync() + val idActual = idIpLookups.performLookups("not") matchIpLookupResult(ioActual, ioExpected) - matchIpLookupResult(evalActual, evalExpected) matchIpLookupResult(idActual, idExpected) } @@ -266,16 +239,11 @@ class IpLookupsTest extends Specification with Tables { ipLookups <- CreateIpLookups[IO].createFromFiles(None, None, None, None, None, true, 0) res <- ipLookups.performLookups("67.43.156.0") } yield res).unsafeRunSync() - val evalActual = (for { - ipLookups <- CreateIpLookups[Eval].createFromFiles(None, None, None, None, None, true, 0) - res <- ipLookups.performLookups("67.43.156.0") - } yield res).value val idActual = CreateIpLookups[Id] .createFromFiles(None, None, None, None, None, true, 0) .performLookups("67.43.156.0") val expected = IpLookupResult(None, None, None, None, None, None) matchIpLookupResult(ioActual, expected) - matchIpLookupResult(evalActual, expected) matchIpLookupResult(idActual, expected) } }