diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e438e20..71dfbbb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,10 +20,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Java and Scala - uses: olafurpg/setup-scala@v12 + uses: olafurpg/setup-scala@v14 with: java-version: ${{ matrix.java }} @@ -31,7 +31,7 @@ jobs: uses: reugn/github-action-aerospike@v1 - name: Cache SBT - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.ivy2/cache diff --git a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AerospikeHandler.scala b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AerospikeHandler.scala index 4f11e79..0553cb3 100644 --- a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AerospikeHandler.scala +++ b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AerospikeHandler.scala @@ -134,6 +134,18 @@ class AerospikeHandler(protected val client: IAerospikeClient)(implicit ec: Exec listener.future } + override def commit(txn: Txn): Future[CommitStatus] = { + val listener = new ScalaCommitListener + client.commit(null, listener, txn) + listener.future + } + + override def abort(txn: Txn): Future[AbortStatus] = { + val listener = new ScalaAbortListener + client.abort(null, listener, txn) + listener.future + } + override def execute(statement: Statement, operations: Operation*) (implicit policy: WritePolicy): Future[ExecuteTask] = { Future(client.execute(policy, statement, operations: _*)) diff --git a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AsyncHandler.scala b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AsyncHandler.scala index 94318c3..b4f9a6f 100644 --- a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AsyncHandler.scala +++ b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AsyncHandler.scala @@ -87,6 +87,14 @@ trait AsyncHandler[F[_]] { def operateBatchRecord(records: Seq[BatchRecord]) (implicit policy: BatchPolicy = null): F[Boolean] + //------------------------------------------------------- + // Multi-Record Transactions + //------------------------------------------------------- + + def commit(txn: Txn): F[CommitStatus] + + def abort(txn: Txn): F[AbortStatus] + //------------------------------------------------------- // Scan Operations //------------------------------------------------------- diff --git a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/listener/ScalaAbortListener.scala b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/listener/ScalaAbortListener.scala new file mode 100644 index 0000000..de15ad0 --- /dev/null +++ b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/listener/ScalaAbortListener.scala @@ -0,0 +1,11 @@ +package io.github.reugn.aerospike.scala.listener + +import com.aerospike.client.AbortStatus +import com.aerospike.client.listener.AbortListener + +class ScalaAbortListener extends AbortListener with PromiseLike[AbortStatus] { + + override def onSuccess(status: AbortStatus): Unit = { + success(status) + } +} diff --git a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/listener/ScalaCommitListener.scala b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/listener/ScalaCommitListener.scala new file mode 100644 index 0000000..61f8b95 --- /dev/null +++ b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/listener/ScalaCommitListener.scala @@ -0,0 +1,15 @@ +package io.github.reugn.aerospike.scala.listener + +import com.aerospike.client.listener.CommitListener +import com.aerospike.client.{AerospikeException, CommitStatus} + +class ScalaCommitListener extends CommitListener with PromiseLike[CommitStatus] { + + override def onSuccess(status: CommitStatus): Unit = { + success(status) + } + + override def onFailure(exception: AerospikeException.Commit): Unit = { + failure(exception) + } +} diff --git a/aerospike-monix/src/main/scala/io/github/reugn/aerospike/scala/monixeffect/MonixAerospikeHandler.scala b/aerospike-monix/src/main/scala/io/github/reugn/aerospike/scala/monixeffect/MonixAerospikeHandler.scala index 6948953..b3bf9b3 100644 --- a/aerospike-monix/src/main/scala/io/github/reugn/aerospike/scala/monixeffect/MonixAerospikeHandler.scala +++ b/aerospike-monix/src/main/scala/io/github/reugn/aerospike/scala/monixeffect/MonixAerospikeHandler.scala @@ -105,6 +105,14 @@ class MonixAerospikeHandler(protected val client: IAerospikeClient) Task(client.operate(policy, records.asJava)) } + override def commit(txn: Txn): Task[CommitStatus] = { + Task(client.commit(txn)) + } + + override def abort(txn: Txn): Task[AbortStatus] = { + Task(client.abort(txn)) + } + override def scanNodeName(nodeName: String, ns: String, set: String, binNames: String*) (implicit policy: ScanPolicy): Task[List[KeyRecord]] = { Task { diff --git a/aerospike-zio/src/main/scala/io/github/reugn/aerospike/scala/zioeffect/ZioAerospikeHandler.scala b/aerospike-zio/src/main/scala/io/github/reugn/aerospike/scala/zioeffect/ZioAerospikeHandler.scala index 342f598..293b030 100644 --- a/aerospike-zio/src/main/scala/io/github/reugn/aerospike/scala/zioeffect/ZioAerospikeHandler.scala +++ b/aerospike-zio/src/main/scala/io/github/reugn/aerospike/scala/zioeffect/ZioAerospikeHandler.scala @@ -105,6 +105,14 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient) ZIO.attemptBlocking(client.operate(policy, records.asJava)) } + override def commit(txn: Txn): Task[CommitStatus] = { + ZIO.attemptBlocking(client.commit(txn)) + } + + override def abort(txn: Txn): Task[AbortStatus] = { + ZIO.attemptBlocking(client.abort(txn)) + } + override def scanNodeName(nodeName: String, ns: String, set: String, binNames: String*) (implicit policy: ScanPolicy): Task[List[KeyRecord]] = { ZIO.attemptBlocking { diff --git a/build.sbt b/build.sbt index 2a5dbc4..dbebd7e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,23 +1,23 @@ -val ZIOVersion = "2.0.16" +val ZIOVersion = "2.0.22" val MonixVersion = "3.4.1" -val AerospikeVersion = "7.1.0" -val AkkaStreamVersion = "2.8.4" -val NettyVersion = "4.1.97.Final" +val AerospikeVersion = "9.0.2" +val AkkaStreamVersion = "2.8.8" +val NettyVersion = "4.1.116.Final" lazy val commonSettings = Seq( organization := "io.github.reugn", - scalaVersion := "2.12.18", - crossScalaVersions := Seq(scalaVersion.value, "2.13.11"), + scalaVersion := "2.12.20", + crossScalaVersions := Seq(scalaVersion.value, "2.13.15"), libraryDependencies ++= Seq( - "com.aerospike" % "aerospike-client" % AerospikeVersion, + "com.aerospike" % "aerospike-client-jdk8" % AerospikeVersion, "com.typesafe.akka" %% "akka-stream" % AkkaStreamVersion, "io.netty" % "netty-transport" % NettyVersion, "io.netty" % "netty-transport-native-epoll" % NettyVersion classifier "linux-x86_64", "io.netty" % "netty-transport-native-kqueue" % NettyVersion classifier "osx-x86_64", "io.netty" % "netty-handler" % NettyVersion, - "com.typesafe" % "config" % "1.4.2", - "org.scalatest" %% "scalatest" % "3.2.16" % Test + "com.typesafe" % "config" % "1.4.3", + "org.scalatest" %% "scalatest" % "3.2.19" % Test ), scalacOptions := Seq( diff --git a/project/build.properties b/project/build.properties index 0ac3d3f..25ff9a6 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.9.4 \ No newline at end of file +sbt.version = 1.10.6 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 9946d0c..ce60852 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,2 @@ -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21") -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") \ No newline at end of file +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.12.2") +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1") \ No newline at end of file diff --git a/version.sbt b/version.sbt index df2fd93..9da2612 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "0.6.0" \ No newline at end of file +ThisBuild / version := "0.7.0" \ No newline at end of file