From c9533ef23556b62b6ff4f9fb83e3c2bfe64781db Mon Sep 17 00:00:00 2001 From: reugn Date: Sat, 2 Sep 2023 13:35:18 +0300 Subject: [PATCH 1/9] remove optional index name parameter --- .../github/reugn/aerospike/scala/model/QueryStatement.scala | 5 ----- .../github/reugn/aerospike/scala/AerospikeHandlerTest.scala | 1 - 2 files changed, 6 deletions(-) diff --git a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/model/QueryStatement.scala b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/model/QueryStatement.scala index b5d9c11..7b5bdca 100644 --- a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/model/QueryStatement.scala +++ b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/model/QueryStatement.scala @@ -7,26 +7,21 @@ case class QueryStatement( namespace: String, setName: Option[String] = None, binNames: Option[Seq[String]] = None, - secondaryIndexName: Option[String] = None, secondaryIndexFilter: Option[Filter] = None, partitionFilter: Option[PartitionFilter] = None, operations: Option[Seq[Operation]] = None, maxRecords: Option[Long] = None, recordsPerSecond: Option[Int] = None ) { - lazy val statement: Statement = { val statement: Statement = new Statement statement.setNamespace(namespace) setName.foreach(statement.setSetName) binNames.foreach(bins => statement.setBinNames(bins: _*)) - secondaryIndexName.foreach(statement.setIndexName) secondaryIndexFilter.foreach(statement.setFilter) operations.foreach(ops => statement.setOperations(ops.toArray)) maxRecords.foreach(statement.setMaxRecords) recordsPerSecond.foreach(statement.setRecordsPerSecond) statement } - - lazy val isScan: Boolean = secondaryIndexName.isEmpty || secondaryIndexFilter.isEmpty } diff --git a/aerospike-core/src/test/scala/io/github/reugn/aerospike/scala/AerospikeHandlerTest.scala b/aerospike-core/src/test/scala/io/github/reugn/aerospike/scala/AerospikeHandlerTest.scala index 299d572..94bc69d 100644 --- a/aerospike-core/src/test/scala/io/github/reugn/aerospike/scala/AerospikeHandlerTest.scala +++ b/aerospike-core/src/test/scala/io/github/reugn/aerospike/scala/AerospikeHandlerTest.scala @@ -197,7 +197,6 @@ class AerospikeHandlerTest extends AsyncFlatSpec with TestCommon with Matchers w val queryStatement = QueryStatement( namespace, setName = Some(set), - secondaryIndexName = Some("idx1"), secondaryIndexFilter = Some(Filter.equal("bin1", 1)) ) assertThrows[AerospikeException] { From 6be62aea76f38cb74efd0f09d5c02f3d34dec259 Mon Sep 17 00:00:00 2001 From: reugn Date: Sat, 2 Sep 2023 13:39:56 +0300 Subject: [PATCH 2/9] check if Netty native transport is available --- .../github/reugn/aerospike/scala/EventLoopProvider.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/EventLoopProvider.scala b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/EventLoopProvider.scala index cdc63f5..eb1a919 100644 --- a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/EventLoopProvider.scala +++ b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/EventLoopProvider.scala @@ -2,8 +2,8 @@ package io.github.reugn.aerospike.scala import com.aerospike.client.async.{EventLoop, EventLoops, EventPolicy, NettyEventLoops} import io.github.reugn.aerospike.scala.util.{Linux, Mac, OperatingSystem} -import io.netty.channel.epoll.EpollEventLoopGroup -import io.netty.channel.kqueue.KQueueEventLoopGroup +import io.netty.channel.epoll.{Epoll, EpollEventLoopGroup} +import io.netty.channel.kqueue.{KQueue, KQueueEventLoopGroup} import io.netty.channel.nio.NioEventLoopGroup object EventLoopProvider { @@ -12,9 +12,9 @@ object EventLoopProvider { private[scala] lazy val eventLoops: EventLoops = { val eventLoopGroup = OperatingSystem() match { - case Linux => + case Linux if Epoll.isAvailable => new EpollEventLoopGroup(nThreads) - case Mac => + case Mac if KQueue.isAvailable => new KQueueEventLoopGroup(nThreads) case _ => new NioEventLoopGroup(nThreads) From 9a06777bbef6ff6c3d7d8d6d730a4613c0ef94a1 Mon Sep 17 00:00:00 2001 From: reugn Date: Thu, 7 Sep 2023 20:03:24 +0300 Subject: [PATCH 3/9] update sbt to 1.9.4 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index fcc6ebc..0ac3d3f 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.7.1 \ No newline at end of file +sbt.version = 1.9.4 \ No newline at end of file From 884d0a487866897f557fd732630033885670d0ea Mon Sep 17 00:00:00 2001 From: reugn Date: Fri, 8 Sep 2023 10:19:06 +0300 Subject: [PATCH 4/9] add metrics policy to the client builder --- .../reugn/aerospike/scala/AerospikeClientBuilder.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AerospikeClientBuilder.scala b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AerospikeClientBuilder.scala index abea450..05d8557 100644 --- a/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AerospikeClientBuilder.scala +++ b/aerospike-core/src/main/scala/io/github/reugn/aerospike/scala/AerospikeClientBuilder.scala @@ -1,12 +1,13 @@ package io.github.reugn.aerospike.scala +import com.aerospike.client.metrics.MetricsPolicy import com.aerospike.client.policy.{AuthMode, ClientPolicy} import com.aerospike.client.{AerospikeClient, Host, IAerospikeClient} import com.typesafe.config.Config import io.github.reugn.aerospike.scala.AerospikeClientBuilder._ import io.github.reugn.aerospike.scala.Policies.ClientPolicyImplicits._ -class AerospikeClientBuilder(config: Config) { +class AerospikeClientBuilder(config: Config, metricsPolicy: Option[MetricsPolicy]) { private def buildClientPolicy(): ClientPolicy = { val policy = new ClientPolicy(); @@ -33,7 +34,7 @@ class AerospikeClientBuilder(config: Config) { } def build(): IAerospikeClient = { - Option(config.getString("aerospike.hostList")) map { + val client = Option(config.getString("aerospike.hostList")) map { hostList => new AerospikeClient(buildClientPolicy(), Host.parseHosts(hostList, defaultPort): _*) } getOrElse { @@ -41,6 +42,8 @@ class AerospikeClientBuilder(config: Config) { val port = Option(config.getInt("aerospike.port")).getOrElse(defaultPort) new AerospikeClient(buildClientPolicy(), hostname, port) } + metricsPolicy.foreach(policy => client.enableMetrics(policy)) + client } } @@ -48,5 +51,5 @@ object AerospikeClientBuilder { private[aerospike] val defaultHostName = "localhost" private[aerospike] val defaultPort = 3000 - def apply(config: Config): AerospikeClientBuilder = new AerospikeClientBuilder(config) + def apply(config: Config): AerospikeClientBuilder = new AerospikeClientBuilder(config, None) } From 4b1f61c23a64277522c0e2ee2d256c049ad674c2 Mon Sep 17 00:00:00 2001 From: reugn Date: Fri, 8 Sep 2023 10:22:29 +0300 Subject: [PATCH 5/9] update sbt plugin versions --- project/plugins.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 26689d9..9946d0c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,2 @@ -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13") -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") \ No newline at end of file +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21") +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") \ No newline at end of file From a97b44417cb4d0282d462350ca803259671ad134 Mon Sep 17 00:00:00 2001 From: reugn Date: Fri, 8 Sep 2023 10:25:02 +0300 Subject: [PATCH 6/9] update action versions in the build workflow --- .github/workflows/build.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04d9972..e438e20 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Java and Scala uses: olafurpg/setup-scala@v12 @@ -30,17 +30,13 @@ jobs: - name: Set up Aerospike Database uses: reugn/github-action-aerospike@v1 - - name: Cache sbt - uses: actions/cache@v2 + - name: Cache SBT + uses: actions/cache@v3 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') }} + ~/.sbt + key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }} - name: Build and test run: sbt ++${{ matrix.scala }} test \ No newline at end of file From 6d1e65c6a41c7dd0dfddf1cd3b05cea329597759 Mon Sep 17 00:00:00 2001 From: reugn Date: Sat, 9 Sep 2023 12:52:43 +0300 Subject: [PATCH 7/9] update dependencies --- build.sbt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 380e6d8..2a5dbc4 100644 --- a/build.sbt +++ b/build.sbt @@ -1,13 +1,13 @@ -val ZIOVersion = "1.0.16" +val ZIOVersion = "2.0.16" val MonixVersion = "3.4.1" -val AerospikeVersion = "6.1.0" -val AkkaStreamVersion = "2.6.19" -val NettyVersion = "4.1.79.Final" +val AerospikeVersion = "7.1.0" +val AkkaStreamVersion = "2.8.4" +val NettyVersion = "4.1.97.Final" lazy val commonSettings = Seq( organization := "io.github.reugn", - scalaVersion := "2.12.16", - crossScalaVersions := Seq(scalaVersion.value, "2.13.8"), + scalaVersion := "2.12.18", + crossScalaVersions := Seq(scalaVersion.value, "2.13.11"), libraryDependencies ++= Seq( "com.aerospike" % "aerospike-client" % AerospikeVersion, @@ -17,7 +17,7 @@ lazy val commonSettings = Seq( "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.12" % Test + "org.scalatest" %% "scalatest" % "3.2.16" % Test ), scalacOptions := Seq( @@ -69,7 +69,7 @@ lazy val zio = (project in file("aerospike-zio")).settings( ).settings(libraryDependencies ++= Seq( "dev.zio" %% "zio" % ZIOVersion, "dev.zio" %% "zio-streams" % ZIOVersion, - "dev.zio" %% "zio-interop-reactivestreams" % "1.3.12" + "dev.zio" %% "zio-interop-reactivestreams" % "2.0.2" )).dependsOn( core % "test->test;compile->compile" ) From a4a52b76aeca863f0c777c33aca29aac685eedac Mon Sep 17 00:00:00 2001 From: reugn Date: Sat, 9 Sep 2023 12:55:55 +0300 Subject: [PATCH 8/9] upgrade to ZIO 2 --- .../scala/zioeffect/ZioAerospikeHandler.scala | 46 ++++++++--------- .../zioeffect/ZioAerospikeHandlerTest.scala | 49 +++++++++++-------- 2 files changed, 51 insertions(+), 44 deletions(-) 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 11ae514..a10f6ec 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 @@ -8,8 +8,8 @@ import com.aerospike.client.task.ExecuteTask import com.typesafe.config.Config import io.github.reugn.aerospike.scala._ import io.github.reugn.aerospike.scala.model.QueryStatement -import zio.Task import zio.stream.ZStream +import zio.{Task, ZIO} import java.util.Calendar import scala.collection.JavaConverters.seqAsJavaListConverter @@ -19,49 +19,49 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient) with StreamHandler3[ZStream] { override def put(key: Key, bins: Bin*)(implicit policy: WritePolicy): Task[Key] = { - Task(client.put(policy, key, bins: _*)).map(_ => key) + ZIO.attemptBlocking(client.put(policy, key, bins: _*)).map(_ => key) } override def append(key: Key, bins: Bin*)(implicit policy: WritePolicy): Task[Key] = { - Task(client.append(policy, key, bins: _*)).map(_ => key) + ZIO.attemptBlocking(client.append(policy, key, bins: _*)).map(_ => key) } override def prepend(key: Key, bins: Bin*)(implicit policy: WritePolicy): Task[Key] = { - Task(client.prepend(policy, key, bins: _*)).map(_ => key) + ZIO.attemptBlocking(client.prepend(policy, key, bins: _*)).map(_ => key) } override def add(key: Key, bins: Bin*)(implicit policy: WritePolicy): Task[Key] = { - Task(client.add(policy, key, bins: _*)).map(_ => key) + ZIO.attemptBlocking(client.add(policy, key, bins: _*)).map(_ => key) } override def delete(key: Key)(implicit policy: WritePolicy): Task[Boolean] = { - Task(client.delete(policy, key)) + ZIO.attemptBlocking(client.delete(policy, key)) } override def deleteBatch(keys: Seq[Key]) (implicit policy: BatchPolicy, batchDeletePolicy: BatchDeletePolicy): Task[BatchResults] = { - Task(client.delete(policy, batchDeletePolicy, keys.toArray)) + ZIO.attemptBlocking(client.delete(policy, batchDeletePolicy, keys.toArray)) } override def truncate(ns: String, set: String, beforeLastUpdate: Option[Calendar] = None) (implicit policy: InfoPolicy): Task[Unit] = { - Task(client.truncate(policy, ns, set, beforeLastUpdate.orNull)) + ZIO.attemptBlocking(client.truncate(policy, ns, set, beforeLastUpdate.orNull)) } override def touch(key: Key)(implicit policy: WritePolicy): Task[Key] = { - Task(client.touch(policy, key)).map(_ => key) + ZIO.attemptBlocking(client.touch(policy, key)).map(_ => key) } override def exists(key: Key)(implicit policy: Policy): Task[Boolean] = { - Task(client.exists(policy, key)) + ZIO.attemptBlocking(client.exists(policy, key)) } override def existsBatch(keys: Seq[Key])(implicit policy: BatchPolicy): Task[Seq[Boolean]] = { - Task(client.exists(policy, keys.toArray)).map(_.toIndexedSeq) + ZIO.attemptBlocking(client.exists(policy, keys.toArray)).map(_.toIndexedSeq) } override def get(key: Key, binNames: String*)(implicit policy: Policy): Task[Record] = { - Task { + ZIO.attemptBlocking { if (binNames.toArray.length > 0) client.get(policy, key, binNames: _*) else @@ -70,7 +70,7 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient) } override def getBatch(keys: Seq[Key], binNames: String*)(implicit policy: BatchPolicy): Task[Seq[Record]] = { - Task { + ZIO.attemptBlocking { if (binNames.toArray.length > 0) client.get(policy, keys.toArray, binNames: _*) else @@ -81,33 +81,33 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient) } override def getBatchOp(keys: Seq[Key], operations: Operation*)(implicit policy: BatchPolicy): Task[Seq[Record]] = { - Task(client.get(policy, keys.toArray, operations: _*)) + ZIO.attemptBlocking(client.get(policy, keys.toArray, operations: _*)) } override def getHeader(key: Key)(implicit policy: Policy): Task[Record] = { - Task(client.getHeader(policy, key)) + ZIO.attemptBlocking(client.getHeader(policy, key)) } override def getHeaderBatch(keys: Seq[Key])(implicit policy: BatchPolicy): Task[Seq[Record]] = { - Task(client.getHeader(policy, keys.toArray)).map(_.toIndexedSeq) + ZIO.attemptBlocking(client.getHeader(policy, keys.toArray)).map(_.toIndexedSeq) } override def operate(key: Key, operations: Operation*)(implicit policy: WritePolicy): Task[Record] = { - Task(client.operate(policy, key, operations: _*)) + ZIO.attemptBlocking(client.operate(policy, key, operations: _*)) } override def operateBatch(keys: Seq[Key], operations: Operation*) (implicit policy: BatchPolicy, batchWritePolicy: BatchWritePolicy): Task[BatchResults] = { - Task(client.operate(policy, batchWritePolicy, keys.toArray, operations: _*)) + ZIO.attemptBlocking(client.operate(policy, batchWritePolicy, keys.toArray, operations: _*)) } override def operateBatchRecord(records: Seq[BatchRecord])(implicit policy: BatchPolicy): Task[Boolean] = { - Task(client.operate(policy, records.asJava)) + ZIO.attemptBlocking(client.operate(policy, records.asJava)) } override def scanNodeName(nodeName: String, ns: String, set: String, binNames: String*) (implicit policy: ScanPolicy): Task[List[KeyRecord]] = { - Task { + ZIO.attemptBlocking { val callback = RecordScanCallback() client.scanNode(policy, nodeName, ns, set, callback, binNames: _*) callback.getRecordSet @@ -116,7 +116,7 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient) override def scanNode(node: Node, ns: String, set: String, binNames: String*) (implicit policy: ScanPolicy): Task[List[KeyRecord]] = { - Task { + ZIO.attemptBlocking { val callback = RecordScanCallback() client.scanNode(policy, node, ns, set, callback, binNames: _*) callback.getRecordSet @@ -125,11 +125,11 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient) override def execute(statement: Statement, operations: Operation*) (implicit policy: WritePolicy): Task[ExecuteTask] = { - Task(client.execute(policy, statement, operations: _*)) + ZIO.attemptBlocking(client.execute(policy, statement, operations: _*)) } override def info(node: Node, name: String): Task[String] = { - Task(Info.request(node, name)) + ZIO.attemptBlocking(Info.request(node, name)) } override def query(statement: QueryStatement) diff --git a/aerospike-zio/src/test/scala/io/github/reugn/aerospike/scala/zioeffect/ZioAerospikeHandlerTest.scala b/aerospike-zio/src/test/scala/io/github/reugn/aerospike/scala/zioeffect/ZioAerospikeHandlerTest.scala index 66f40a4..4ef6cb9 100644 --- a/aerospike-zio/src/test/scala/io/github/reugn/aerospike/scala/zioeffect/ZioAerospikeHandlerTest.scala +++ b/aerospike-zio/src/test/scala/io/github/reugn/aerospike/scala/zioeffect/ZioAerospikeHandlerTest.scala @@ -8,6 +8,7 @@ import org.scalatest.BeforeAndAfter import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import zio.Runtime.{default => rt} +import zio.{Unsafe, ZIO} class ZioAerospikeHandlerTest extends AnyFlatSpec with TestCommon with Matchers with BeforeAndAfter { @@ -18,23 +19,23 @@ class ZioAerospikeHandlerTest extends AnyFlatSpec with TestCommon with Matchers before { for (t <- populateKeys(client)) { - rt.unsafeRun(t) + unsafeRun(t) } } after { - rt.unsafeRun(deleteKeys(client)) + unsafeRun(deleteKeys(client)) } it should "get record properly" in { val t = client.get(keys(0)) - val record = rt.unsafeRun(t) + val record = unsafeRun(t) record.getLong("intBin") shouldBe 0L } it should "get records properly" in { val t = client.getBatch(keys.toIndexedSeq) - val records = rt.unsafeRun(t) + val records = unsafeRun(t) records.size shouldBe keys.length } @@ -43,7 +44,7 @@ class ZioAerospikeHandlerTest extends AnyFlatSpec with TestCommon with Matchers val multiplier = 10L val mulExp = Exp.build(Exp.mul(Exp.intBin("intBin"), Exp.`val`(multiplier))) val t = client.getBatchOp(keys.toIndexedSeq, ExpOperation.read(mulIntBin, mulExp, ExpReadFlags.DEFAULT)) - val records = rt.unsafeRun(t) + val records = unsafeRun(t) records.size shouldBe keys.length records.zipWithIndex.map { case (rec: Record, i: Int) => val expected = multiplier * i @@ -54,56 +55,56 @@ class ZioAerospikeHandlerTest extends AnyFlatSpec with TestCommon with Matchers } it should "append bin properly" in { - rt.unsafeRun(client.append(keys(0), new Bin("strBin", "_"))) - val record = rt.unsafeRun(client.get(keys(0))) + unsafeRun(client.append(keys(0), new Bin("strBin", "_"))) + val record = unsafeRun(client.get(keys(0))) record.getString("strBin") shouldBe "str_0_" } it should "prepend bin properly" in { - rt.unsafeRun(client.prepend(keys(0), new Bin("strBin", "_"))) - val record = rt.unsafeRun(client.get(keys(0))) + unsafeRun(client.prepend(keys(0), new Bin("strBin", "_"))) + val record = unsafeRun(client.get(keys(0))) record.getString("strBin") shouldBe "_str_0" } it should "add bin properly" in { - rt.unsafeRun(client.add(keys(0), new Bin("intBin", 10))) - val record = rt.unsafeRun(client.get(keys(0))) + unsafeRun(client.add(keys(0), new Bin("intBin", 10))) + val record = unsafeRun(client.get(keys(0))) record.getLong("intBin") shouldBe 10L } it should "delete record properly" in { - val deleteResult = rt.unsafeRun(client.delete(keys(0))) + val deleteResult = unsafeRun(client.delete(keys(0))) deleteResult shouldBe true - val record = rt.unsafeRun(client.get(keys(0))) + val record = unsafeRun(client.get(keys(0))) record shouldBe null } it should "delete batch of records properly" in { val t = client.deleteBatch(keys.toSeq) - val result = rt.unsafeRun(t) + val result = unsafeRun(t) result.status shouldBe true } it should "record to be exist" in { - val result = rt.unsafeRun(client.exists(keys(0))) + val result = unsafeRun(client.exists(keys(0))) result shouldBe true } it should "records to be exist" in { - val result = rt.unsafeRun(client.existsBatch(keys.toIndexedSeq)) + val result = unsafeRun(client.existsBatch(keys.toIndexedSeq)) result.forall(identity) shouldBe true } it should "operate bin properly" in { - rt.unsafeRun(client.operate(keys(0), Operation.put(new Bin("intBin", 100)))) - val record = rt.unsafeRun(client.get(keys(0))) + unsafeRun(client.operate(keys(0), Operation.put(new Bin("intBin", 100)))) + val record = unsafeRun(client.get(keys(0))) record.getLong("intBin") shouldBe 100L } it should "operate batch of records properly" in { val t = client.operateBatch(keys.toSeq, Operation.put(new Bin("intBin", 100))) - val result = rt.unsafeRun(t) + val result = unsafeRun(t) result.status shouldBe true } @@ -112,13 +113,19 @@ class ZioAerospikeHandlerTest extends AnyFlatSpec with TestCommon with Matchers List(new BatchWrite(keys(0), Array(Operation.put(new Bin("intBin", 100))))) ++ keys.slice(1, numberOfKeys).map(new BatchDelete(_)).toList val t = client.operateBatchRecord(records) - val result = rt.unsafeRun(t) + val result = unsafeRun(t) result shouldBe true } it should "query all properly" in { val queryStatement = QueryStatement(namespace, setName = Some(set)) val t = client.query(queryStatement).runCollect - rt.unsafeRun(t).length shouldBe numberOfKeys + unsafeRun(t).length shouldBe numberOfKeys + } + + private def unsafeRun[E, A](task: ZIO[Any, E, A]): A = { + Unsafe.unsafe { implicit unsafe => + rt.unsafe.run(task).getOrThrowFiberFailure() + } } } From 93b7fd13f409734b3ad1278f1735b746d6909955 Mon Sep 17 00:00:00 2001 From: reugn Date: Sat, 9 Sep 2023 12:57:29 +0300 Subject: [PATCH 9/9] v0.6.0 --- version.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.sbt b/version.sbt index 319ffc3..df2fd93 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "0.5.0" \ No newline at end of file +ThisBuild / version := "0.6.0" \ No newline at end of file