Skip to content

Commit

Permalink
Merge c4864bb into 351893d
Browse files Browse the repository at this point in the history
  • Loading branch information
istreeter authored Jan 24, 2023
2 parents 351893d + c4864bb commit f662aea
Show file tree
Hide file tree
Showing 44 changed files with 190 additions and 150 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ project/plugins/project/

.bsp/
.idea/
.metals
.bloop
.vscode
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 2.2.1 (2023-01-24)
--------------------------
Update links in Readme (#205)
Rename license file for GitHub (#204)
Update copyright notice to 2023 (#225)
Build and publish for Scala3 (#224)

Version 2.2.0 (2022-11-21)
--------------------------
Add invalidation for the schema-list cache (#215)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-2.0.txt → LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2014-2022 Snowplow Analytics Ltd.
Copyright 2014-2023 Snowplow Analytics Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
[![License][license-image]][license]
[![Coverage Status][coveralls-image]][coveralls]

A Scala client and resolver for **[Iglu schema repositories][iglu-wiki]** from the team at **[Snowplow Analytics][snowplow-website]**.
A Scala client and resolver for **[Iglu schema repositories][iglu-docs]** from the team at **[Snowplow Analytics][snowplow-website]**.

Iglu Scala Client is used extensively in **[Snowplow][snowplow-repo]** to validate self-describing JSONs. For a presentation on how we came to build Iglu, see **[this blog post][snowplow-schema-post]**.

![scala-client-img][scala-client-img]

## Installation

The latest version of Iglu Scala Client is 2.2.0, which currently works with Scala 2.12 and 2.13.
The latest version of Iglu Scala Client is 2.2.1, which works with Scala 2.12, 2.13, and 3.

If you're using SBT, add the following lines to your build file:

```scala
val igluClient = "com.snowplowanalytics" %% "iglu-scala-client" % "2.2.0"
val igluClient = "com.snowplowanalytics" %% "iglu-scala-client" % "2.2.1"
```

## API
Expand Down Expand Up @@ -104,7 +102,7 @@ or there some kind of resolution problems, or simply nothing (`Unit`) in case of

## Copyright and license

Iglu Scala Client is copyright 2014-2022 Snowplow Analytics Ltd.
Iglu Scala Client is copyright 2014-2023 Snowplow Analytics Ltd.

Licensed under the **[Apache License, Version 2.0][license]** (the "License");
you may not use this software except in compliance with the License.
Expand All @@ -115,24 +113,22 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

[scala-client-img]: https://github.com/snowplow/iglu/wiki/technical-documentation/images/iglu-clients.png

[iglu-wiki]: https://github.com/snowplow/iglu/wiki
[snowplow-schema-post]: http://snowplowanalytics.com/blog/2014/06/06/making-snowplow-schemas-flexible-a-technical-approach/
[resolver-config]: https://github.com/snowplow/iglu/wiki/Iglu-client-configuration
[iglu-docs]: https://docs.snowplow.io/docs/pipeline-components-and-applications/iglu/
[snowplow-schema-post]: https://snowplow.io/blog/making-snowplow-schemas-flexible-a-technical-approach/
[resolver-config]: https://docs.snowplow.io/docs/pipeline-components-and-applications/iglu/iglu-resolver/

[snowplow-repo]: https://github.com/snowplow/snowplow
[snowplow-website]: http://snowplowanalytics.com
[snowplow-website]: http://snowplow.io

[techdocs-image]: https://d3i6fms1cm1j0i.cloudfront.net/github/images/techdocs.png
[setup-image]: https://d3i6fms1cm1j0i.cloudfront.net/github/images/setup.png
[roadmap-image]: https://d3i6fms1cm1j0i.cloudfront.net/github/images/roadmap.png
[contributing-image]: https://d3i6fms1cm1j0i.cloudfront.net/github/images/contributing.png

[techdocs]: https://docs.snowplowanalytics.com/docs/pipeline-components-and-applications/iglu/iglu-clients/
[setup]: https://docs.snowplowanalytics.com/docs/pipeline-components-and-applications/iglu/iglu-clients/scala-client-setup/
[techdocs]: https://docs.snowplow.io/docs/pipeline-components-and-applications/iglu/iglu-clients/
[setup]: https://docs.snowplow.io/docs/pipeline-components-and-applications/iglu/iglu-clients/scala-client-setup/
[roadmap]: https://github.com/snowplow/snowplow/projects/7
[contributing]: https://docs.snowplowanalytics.com/docs/contributing/
[contributing]: https://docs.snowplow.io/docs/contributing/

[ci]: https://github.com/snowplow/iglu-scala-client/actions?query=workflow%3ACI
[ci-image]: https://github.com/snowplow/iglu-scala-client/workflows/CI/badge.svg
Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down Expand Up @@ -79,6 +79,7 @@ lazy val http4s = (project in file("modules/http4s"))
libraryDependencies ++= Seq(
Dependencies.Libraries.http4sClient,
Dependencies.Libraries.http4sCirce,
Dependencies.Libraries.catsEffect,
// Scala (test only)
Dependencies.Libraries.circeCore,
Dependencies.Libraries.specs2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2018-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down Expand Up @@ -122,7 +122,7 @@ private[registries] object Utils {
else
s.asRight
)
.map(SchemaList.apply)
.map(SchemaList.parseUnsafe)
} catch {
case NonFatal(e) =>
e match {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2012-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down Expand Up @@ -45,7 +45,16 @@ package object snowplow {
number match {
case _: JsonBiggerDecimal | _: JsonBigDecimal =>
number.toBigDecimal
.map(bigDecimal => DecimalNode.valueOf(bigDecimal.underlying))
.map(bigDecimal => {
if (bigDecimal.isValidInt)
IntNode.valueOf(bigDecimal.intValue)
else if (bigDecimal.isValidLong) {
LongNode.valueOf(bigDecimal.longValue)
} else if (bigDecimal.isWhole) {
BigIntegerNode.valueOf(bigDecimal.toBigInt.underlying)
} else
DecimalNode.valueOf(bigDecimal.underlying)
})
.getOrElse(TextNode.valueOf(number.toString))
case JsonLong(x) => LongNode.valueOf(x)
case JsonDouble(x) => DoubleNode.valueOf(x)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2012-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2022 Snowplow Analytics Ltd. All rights reserved.
* Copyright (c) 2018-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
Expand All @@ -19,6 +19,7 @@ import com.snowplowanalytics.iglu.client.resolver.registries.{Registry, Registry
import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer}
import io.circe.Json
import org.specs2.Specification
import org.specs2.matcher.MatchResult

import java.time.Instant
import scala.concurrent.duration.DurationInt
Expand All @@ -29,7 +30,8 @@ class ResolverCacheSpec extends Specification {
Combine failures during putSchema $e2
Should create a resolver cache if cache size > 0 and TTL is none or more than 0 $e3
"""
def e1 = {

def e1: MatchResult[Product] = {
import ResolverCacheSpec._

val key = SchemaKey("com.acme", "schema", "jsonschema", SchemaVer.Full(1, 0, 0))
Expand All @@ -53,7 +55,7 @@ class ResolverCacheSpec extends Specification {
schemaResult and stateResult
}

def e2 = {
def e2: MatchResult[Any] = {
import ResolverCacheSpec._

val key = SchemaKey("com.acme", "schema", "jsonschema", SchemaVer.Full(1, 0, 0))
Expand All @@ -77,7 +79,7 @@ class ResolverCacheSpec extends Specification {
)
)

val expectedLookup = Map(
val expectedLookup: LookupFailureMap = Map(
Registry.Http(Registry.Config("one", 1, List()), null) -> LookupHistory(
Set(RegistryError.NotFound, RegistryError.RepoFailure("Doesn't matter")),
4,
Expand All @@ -97,8 +99,9 @@ class ResolverCacheSpec extends Specification {
result <- cacheUnsafe.putSchema(key, failure2.asLeft[Json])
} yield result

val (_, result) = test.run(RegistryState.init).value
result must beLeft(expectedLookup)
val (_, result: SchemaLookup) = test.run(RegistryState.init).value
// something odd happens with implicit conversions on scala3
result must_== Left(expectedLookup)
}

def e3 = {
Expand Down
Loading

0 comments on commit f662aea

Please sign in to comment.