Skip to content

Commit

Permalink
Merge pull request #242 from CleverCloud/Scala3Pekko
Browse files Browse the repository at this point in the history
pekko & scala3 & remove akka in name & bump all
  • Loading branch information
KannarFr authored Jun 11, 2024
2 parents 6d747aa + 2cf77f4 commit 5990551
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 224 deletions.
72 changes: 25 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,90 +23,68 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.11]
java: [temurin@11]
scala: [3.4.2]
java: [temurin@21]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v2
- name: Setup Java (temurin@21)
if: matrix.java == 'temurin@21'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
java-version: 21
cache: sbt

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck

- name: Build project
run: sbt ++${{ matrix.scala }} test
run: sbt '++ ${{ matrix.scala }}' test

- name: Compress target directories
run: tar cf targets.tar target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/v'))
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.11]
java: [temurin@11]
scala: [3.4.2]
java: [temurin@21]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v2
- name: Setup Java (temurin@21)
if: matrix.java == 'temurin@21'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
java-version: 21
cache: sbt

- name: Download target directories (2.13.11)
uses: actions/download-artifact@v2
- name: Download target directories (3.4.2)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-2.13.11-${{ matrix.java }}
name: target-${{ matrix.os }}-3.4.2-${{ matrix.java }}

- name: Inflate target directories (2.13.11)
- name: Inflate target directories (3.4.2)
run: |
tar xf targets.tar
rm targets.tar
Expand All @@ -116,4 +94,4 @@ jobs:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }}
run: sbt ++${{ matrix.scala }} ci-release
run: sbt ci-release
3 changes: 2 additions & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Delete artifacts
shell: bash {0}
run: |
# Customize those three lines with your repository and credentials:
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
Expand All @@ -25,7 +26,7 @@ jobs:
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=/tmp/tmp.$$
TMPFILE=$(mktemp)
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[![Tests](https://github.com/clevercloud/akka-warp10-scala-client/actions/workflows/ci.yml/badge.svg)](https://github.com/CleverCloud/akka-warp10-scala-client/actions/workflows/ci.yml)
[![Tests](https://github.com/clevercloud/warp10-scala-client/actions/workflows/ci.yml/badge.svg)](https://github.com/CleverCloud/warp10-scala-client/actions/workflows/ci.yml)

[![Central Version](https://img.shields.io/maven-central/v/com.clever-cloud/akka-warp10-scala-client_2.13)](https://mvnrepository.com/artifact/com.clever-cloud/akka-warp10-scala-client)
[![Nexus Version](https://img.shields.io/nexus/r/com.clever-cloud/akka-warp10-scala-client_2.13?server=https%3A%2F%2Fs01.oss.sonatype.org)](https://search.maven.org/artifact/com.clever-cloud/akka-warp10-scala-client)
[![Central Version](https://img.shields.io/maven-central/v/com.clever-cloud/warp10-scala-client_3)](https://mvnrepository.com/artifact/com.clever-cloud/warp10-scala-client)

# Scala client for [Warp10 Geo/time series DB](http://www.warp10.io/).


## Documentation

Scaladoc is available [here](https://clevercloud.github.io/akka-warp10-scala-client/latest/api/index.html).
Scaladoc is available [here](https://clevercloud.github.io/warp10-scala-client/latest/api/index.html).

```scala
// to generate documentation on gh-pages branch
Expand All @@ -20,23 +19,25 @@ sbt ghpagesPushSite
Add the library dependency:

```scala
"com.clever-cloud" %% "akka-warp10-scala-client" % "<version>"
"com.clever-cloud" %% "warp10-scala-client" % "<version>"
```

## Configuration

```scala
import akka.actor._
import akka.stream.Materializer
import scala.concurrent.ExecutionContext

import org.apache.pekko
import pekko.actor._
import pekko.stream.Materializer

import com.clevercloud.warp10client._
import com.clevercloud.warp10client.models._
import com.clevercloud.warp10client.models.gts_module._

implicit val executionContext = system.dispatchers.lookup("yourContext")
implicit val actorMaterializer = Materializer.matFromSystem
implicit val warpConfiguration = WarpConfiguration("www.clever-cloud.com")
val warpClient = WarpClient("clever-cloud.com", 80)
given executionContext: ExecutionContext = system.dispatchers.lookup("yourContext")
given warpConfiguration: WarpConfiguration = WarpConfiguration("www.clever-cloud.com")
val warpClient = Warp10Client("clever-cloud.com", 80)
```

## Classical usage
Expand Down Expand Up @@ -72,7 +73,7 @@ warpClient.push(gts: GTS, "WRITE_TOKEN")
warpClient.push(gts: Seq[GTS], "WRITE_TOKEN", batchSize = 300)
```

## Akka Streams usage
## Pekko Streams usage

```scala
Flow[Query[FetchRange]]
Expand Down
102 changes: 52 additions & 50 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,61 +1,58 @@
inThisBuild(
List(
organization := "com.clever-cloud",
homepage := Some(url("https://github.com/clevercloud/akka-warp10-scala-client")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"kannarfr",
"Alexandre DUVAL",
"[email protected]",
url("https://alexandre-duval.fr")
)
),
version := "1.6.14",
name := """akka-warp10-scala-client""",
scalaVersion := "2.13.11",
versionScheme := Some("early-semver"),
scmInfo := Some(
ScmInfo(
url("https://github.com/clevercloud/akka-warp10-scala-client"),
"[email protected]:clevercloud/akka-warp10-scala-client.git"
)
),
libraryDependencies ++= Seq(
"org.apache.commons" % "commons-text" % "1.10.0",
"com.typesafe.akka" %% "akka-actor" % "2.6.19",
"com.typesafe.akka" %% "akka-http" % "10.2.9",
"com.typesafe.akka" %% "akka-stream" % "2.6.19",
"io.circe" %% "circe-core" % "0.14.5",
"io.circe" %% "circe-generic" % "0.14.5",
"io.circe" %% "circe-parser" % "0.14.5",
"ch.qos.logback" % "logback-classic" % "1.4.11",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"org.specs2" %% "specs2-core" % "4.20.2" % Test,
"com.clever-cloud" %% "testcontainers-scala-warp10" % "2.1.0" % Test
),
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-unchecked",
"-Xlint",
"-Xcheckinit",
"-language:postfixOps"
),
Test / parallelExecution := false,
git.remoteRepo := "[email protected]:clevercloud/akka-warp10-scala-client.git"
lazy val circeVersion = "0.14.6"
lazy val pekkoVersion = "1.0.2"
lazy val pekkoHttpVersion = "1.0.1"

ThisBuild / organization := "com.clever-cloud"
ThisBuild / homepage := Some(url("https://github.com/clevercloud/warp10-scala-client"))
ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))
ThisBuild / developers := List(
Developer(
"kannarfr",
"Alexandre DUVAL",
"[email protected]",
url("https://alexandre-duval.fr")
)
)
ThisBuild / version := "1.6.14"
ThisBuild / scalaVersion := "3.4.2"
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/clevercloud/warp10-scala-client"),
"[email protected]:clevercloud/warp10-scala-client.git"
)
)
ThisBuild / libraryDependencies ++= Seq(
"org.apache.commons" % "commons-text" % "1.10.0",
"org.apache.pekko" %% "pekko-actor" % pekkoVersion,
"org.apache.pekko" %% "pekko-stream" % pekkoVersion,
"org.apache.pekko" %% "pekko-http" % pekkoHttpVersion,
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"ch.qos.logback" % "logback-classic" % "1.5.2",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"org.specs2" %% "specs2-core" % "4.20.2" % Test,
"com.clever-cloud" %% "testcontainers-scala-warp10" % "2.1.0" % Test
)
ThisBuild / scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-unchecked",
"-language:postfixOps"
)
ThisBuild / Test / parallelExecution := false
ThisBuild / git.remoteRepo := "[email protected]:clevercloud/warp10-scala-client.git"

enablePlugins(GhpagesPlugin)
enablePlugins(SiteScaladocPlugin)

sonatypeCredentialHost := "s01.oss.sonatype.org"
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"

ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec(JavaSpec.Distribution.Temurin, "21"))
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v")))
ThisBuild / githubWorkflowPublishTargetBranches += RefPredicate.StartsWith(Ref.Tag("v"))
ThisBuild / githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release")))
ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
Expand All @@ -67,3 +64,8 @@ ThisBuild / githubWorkflowPublish := Seq(
)
)
)

lazy val root = (project in file("."))
.settings(
name := "warp10-scala-client"
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.6
sbt.version=1.10.0
10 changes: 3 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")

addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")

addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
addSbtPlugin("com.github.sbt" % "sbt-ghpages" % "0.8.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.23.0")
2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<logger name="org.testcontainers" level="INFO"/>

<root level="DEBUG">
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
9 changes: 5 additions & 4 deletions src/main/scala/com/clevercloud/warp10client/Fetcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import java.util.UUID
import scala.concurrent.Future
import scala.util.{ Failure, Success }

import akka.NotUsed
import akka.http.scaladsl.model._
import akka.stream.scaladsl.Flow
import org.apache.pekko
import pekko.NotUsed
import pekko.http.scaladsl.model._
import pekko.stream.scaladsl.Flow
import com.typesafe.scalalogging.Logger
import org.apache.commons.text.StringEscapeUtils
import org.slf4j.LoggerFactory
Expand All @@ -25,7 +26,7 @@ object Fetcher {
val uuid = UUID.randomUUID
Flow[Query[FetchRange]]
.map(query => fetchRequest(readToken, query))
.map(request => (request -> uuid)) // cf. https://doc.akka.io/docs/akka-http/current/client-side/host-level.html
.map(request => (request -> uuid)) // cf. https://doc.pekko.io/docs/pekko-http/current/client-side/host-level.html
.via(warpClientContext.poolClientFlow)
.filter({ case (_, key) => key == uuid })
.map({ case (responseTry, _) => responseTry })
Expand Down
11 changes: 6 additions & 5 deletions src/main/scala/com/clevercloud/warp10client/Pusher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import java.util.UUID
import scala.concurrent.Future
import scala.util.{ Failure, Success }

import akka.NotUsed
import akka.http.scaladsl.model._
import akka.stream.scaladsl.Flow
import org.apache.pekko
import pekko.NotUsed
import pekko.http.scaladsl.model._
import pekko.stream.scaladsl.Flow

import org.apache.commons.lang3.StringEscapeUtils

Expand All @@ -23,7 +24,7 @@ object Pusher {
val uuid = UUID.randomUUID
Flow[GTS]
.map(gts => pushRequest(gts, writeToken))
.map(request => (request -> uuid)) // cf. https://doc.akka.io/docs/akka-http/current/client-side/host-level.html
.map(request => (request -> uuid)) // cf. https://doc.pekko.io/docs/pekko-http/current/client-side/host-level.html
.via(warpClientContext.poolClientFlow)
.filter({ case (_, key) => key == uuid })
.map({ case (responseTry, _) => responseTry })
Expand All @@ -41,7 +42,7 @@ object Pusher {
val uuid = UUID.randomUUID
Flow[Seq[GTS]]
.map(gtsSeq => pushSeqRequest(gtsSeq, writeToken))
.map(request => (request -> uuid)) // cf. https://doc.akka.io/docs/akka-http/current/client-side/host-level.html
.map(request => (request -> uuid)) // cf. https://doc.pekko.io/docs/pekko-http/current/client-side/host-level.html
.via(warpClientContext.poolClientFlow)
.filter({ case (_, key) => key == uuid })
.map({ case (responseTry, _) => responseTry })
Expand Down
Loading

0 comments on commit 5990551

Please sign in to comment.