Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

akka replacement with pekko migration #252

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ val scalacheck = "org.scalacheck" %% "scalacheck" % "1.14.2"
//val scalameter = "com.github.axel22" %% "scalameter" % "0.4"

val rediscalaDependencies = Seq(
akkaActor,
//akkaActor,
"org.apache.pekko" %% "pekko-actor-typed" % "0.0.0+26544-4c021960-SNAPSHOT",
stm,
akkaTestkit % "test",
//akkaTestkit % "test",
"org.apache.pekko" %% "pekko-actor-testkit-typed" % "0.0.0+26544-4c021960-SNAPSHOT" % Test,
//scalameter % "test",
specs2 % "test",
scalacheck % "test"
Expand All @@ -28,12 +30,16 @@ val rediscalaDependencies = Seq(
val baseSourceUrl = "https://github.com/etaty/rediscala/tree/"

val Scala211 = "2.11.12"
val Scala212 = "2.12.8"

lazy val pekkoResolver1 = "ApachePekkoSnapshots" at "https://repository.apache.org/content/groups/snapshots"
lazy val pekkoResolver2 = "pekko-http-snapshot-repository" at "https://repository.apache.org/content/repositories/snapshots"

lazy val standardSettings = Def.settings(
name := "rediscala",
organization := "com.github.etaty",
scalaVersion := Scala211,
crossScalaVersions := Seq(Scala211, "2.12.10", "2.13.0"),
scalaVersion := Scala212,
crossScalaVersions := Seq(Scala211, Scala212, "2.13.0"),
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html")),
homepage := Some(url("https://github.com/etaty/rediscala")),
scmInfo := Some(ScmInfo(url("https://github.com/etaty/rediscala"), "scm:git:[email protected]:etaty/rediscala.git")),
Expand Down Expand Up @@ -119,6 +125,8 @@ lazy val root = Project(id = "rediscala",
base = file(".")
).settings(
standardSettings,
resolvers += pekkoResolver1,
resolvers += pekkoResolver2,
libraryDependencies ++= rediscalaDependencies
).configs(
BenchTest
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/redis/Converter.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package redis

import akka.util.ByteString
//import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol._
import scala.util.Try
import scala.annotation.{tailrec, implicitNotFound}
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/redis/Operation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package redis

import scala.concurrent.Promise
import redis.protocol.{DecodeResult, RedisReply}
import akka.util.ByteString
//import akka.util.ByteString
import org.apache.pekko.util.ByteString

case class Operation[RedisReplyT <: RedisReply, T](redisCommand: RedisCommand[RedisReplyT, T], promise: Promise[T]) {
def decodeRedisReplyThenComplete(bs: ByteString): DecodeResult[Unit] = {
Expand Down
6 changes: 4 additions & 2 deletions src/main/scala/redis/Redis.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package redis

import akka.actor._
import akka.util.Helpers
//import akka.actor._
import org.apache.pekko.actor.{ActorRef, ActorRefFactory, ActorSystem, Props}
import org.apache.pekko.util.Helpers
//import akka.util.Helpers
import redis.commands._
import scala.concurrent._
import java.net.InetSocketAddress
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/redis/RedisCluster.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package redis

import java.util.concurrent.{ThreadLocalRandom, TimeUnit}

import akka.actor.{ActorRef, ActorSystem}
import akka.event.Logging
import akka.util.ByteString
import org.apache.pekko.actor.{ActorRef, ActorSystem}
import org.apache.pekko.event.Logging
import org.apache.pekko.util.ByteString
import redis.api.clusters.{ClusterNode, ClusterSlot}
import redis.protocol.RedisReply
import redis.util.CRC16
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/RedisCommand.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis

import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol._


Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/RedisPool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package redis

import java.net.InetSocketAddress

import akka.actor.{ActorRef, ActorSystem}
import org.apache.pekko.actor.{ActorRef, ActorSystem}

import scala.concurrent.stm._
import redis.actors.RedisClientActor
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/Request.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package redis
import redis.protocol.RedisReply
import scala.concurrent.{ExecutionContext, Promise, Future}
import scala.collection.immutable.Queue
import akka.actor.ActorRef
import org.apache.pekko.actor.ActorRef
import java.util.concurrent.atomic.AtomicInteger


Expand Down
6 changes: 4 additions & 2 deletions src/main/scala/redis/Sentinel.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package redis

import redis.commands.Sentinel
import akka.actor.{ActorSystem, Props, ActorRef}
import akka.event.Logging
//import akka.actor.{ActorSystem, Props, ActorRef}
import org.apache.pekko.actor.{ActorRef, ActorSystem, Props}
import org.apache.pekko.event.Logging
//import akka.event.Logging
import redis.api.pubsub.{PMessage, Message}
import redis.actors.RedisSubscriberActorWithCallback
import java.net.InetSocketAddress
Expand Down
11 changes: 6 additions & 5 deletions src/main/scala/redis/actors/RedisClientActor.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package redis.actors

import org.apache.pekko.actor.{OneForOneStrategy, PoisonPill, Terminated}
import org.apache.pekko.actor.TypedActor.dispatcher
import java.net.InetSocketAddress

import akka.actor.SupervisorStrategy.Stop
import akka.actor._
import akka.util.{ByteString, ByteStringBuilder}
import org.apache.pekko.actor.SupervisorStrategy.Stop
import org.apache.pekko.actor.{ActorRef, Props}
import org.apache.pekko.util.{ByteString, ByteStringBuilder}
import redis.{Operation, Transaction}

import scala.collection.mutable
Expand All @@ -23,7 +24,7 @@ class RedisClientActor(override val address: InetSocketAddress, getConnectOperat
Seq[Operation[_, _]], onConnectStatus: Boolean => Unit, dispatcherName: String, connectTimeout: Option[FiniteDuration] = None) extends RedisWorkerIO(address, onConnectStatus, connectTimeout) {


import context._
//import context._

var repliesDecoder = initRepliesDecoder()

Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/redis/actors/RedisReplyDecoder.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package redis.actors

import akka.actor.Actor
import org.apache.pekko.actor.Actor
import scala.collection.mutable
import redis.protocol.{FullyDecoded, DecodeResult, RedisProtocolReply, RedisReply}
import akka.util.ByteString
import akka.event.Logging
import org.apache.pekko.util.ByteString
import org.apache.pekko.event.Logging
import scala.annotation.tailrec
import redis.Operation

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/actors/RedisSubscriberActor.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.actors

import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.{Error, MultiBulk, RedisReply}
import redis.api.pubsub._
import java.net.InetSocketAddress
Expand Down
20 changes: 10 additions & 10 deletions src/main/scala/redis/actors/RedisWorkerIO.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package redis.actors

import akka.actor.{ActorLogging, ActorRef, Actor}
import akka.io.Tcp
import akka.util.{ByteStringBuilder, ByteString}
import org.apache.pekko.actor.{ActorLogging, ActorRef, Actor}
import org.apache.pekko.io.Tcp
import org.apache.pekko.util.{ByteStringBuilder, ByteString}
import java.net.InetSocketAddress
import akka.io.Tcp._
import akka.io.Tcp.Connected
import akka.io.Tcp.Register
import akka.io.Tcp.Connect
import akka.io.Tcp.CommandFailed
import akka.io.Tcp.Received
import org.apache.pekko.io.Tcp._
import org.apache.pekko.io.Tcp.Connected
import org.apache.pekko.io.Tcp.Register
import org.apache.pekko.io.Tcp.Connect
import org.apache.pekko.io.Tcp.CommandFailed
import org.apache.pekko.io.Tcp.Received
import scala.concurrent.duration.FiniteDuration

abstract class RedisWorkerIO(val address: InetSocketAddress, onConnectStatus: Boolean => Unit, connectTimeout: Option[FiniteDuration] = None) extends Actor with ActorLogging {
Expand All @@ -18,7 +18,7 @@ abstract class RedisWorkerIO(val address: InetSocketAddress, onConnectStatus: Bo

import context._

val tcp = akka.io.IO(Tcp)(context.system)
val tcp = org.apache.pekko.io.IO(Tcp)(context.system)

// todo watch tcpWorker
var tcpWorker: ActorRef = null
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/BLists.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package redis.api.blists

import scala.concurrent.duration.{Duration, FiniteDuration}
import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.{RedisReply, MultiBulk, Bulk}

case class Blpop[KK: ByteStringSerializer, R: ByteStringDeserializer](keys: Seq[KK], timeout: FiniteDuration = Duration.Zero)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Clusters.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.api.clusters

import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.RedisCommand
import redis.protocol.{DecodeResult, Bulk, MultiBulk, RedisProtocolReply, RedisReply}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Connection.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.connection

import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.Status

case class Auth[V](value: V)(implicit convert: ByteStringSerializer[V]) extends RedisCommandStatus[Status] {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Hashes.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.hashes

import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import scala.collection.mutable
import scala.annotation.tailrec
import redis.protocol.{RedisReply, MultiBulk}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/HyperLogLog.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.api.hyperloglog

import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.{RedisCommandIntegerLong, RedisCommandStatusBoolean, ByteStringSerializer}

case class Pfadd[K, V](key: K, values: Seq[V])(implicit redisKey: ByteStringSerializer[K], convert: ByteStringSerializer[V]) extends RedisCommandIntegerLong {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Keys.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.keys

import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol._
import scala.concurrent.duration.FiniteDuration
import redis.api.Order
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Lists.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.lists

import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.api.ListPivot
import redis.protocol.MultiBulk

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Publish.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.publish

import redis.{RedisCommandIntegerLong, ByteStringSerializer}
import akka.util.ByteString
import org.apache.pekko.util.ByteString

case class Publish[A](channel: String, value: A)(implicit convert: ByteStringSerializer[A]) extends RedisCommandIntegerLong {
val isMasterOnly = true
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Scripting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.io.File
import java.security.MessageDigest
import redis.protocol.{MultiBulk, Bulk}
import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString

object RedisScript {
def fromFile(file: File): RedisScript = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Sentinel.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api

import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.MultiBulk

case class SenMasters() extends RedisCommandMultiBulk[Seq[Map[String,String]]] {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Servers.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.servers

import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.{MultiBulk, Bulk}
import redis.api.ShutdownModifier

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Sets.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.sets

import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.RedisReply

case class Sadd[K, V](key: K, members: Seq[V])(implicit redisKey: ByteStringSerializer[K], convert: ByteStringSerializer[V]) extends SimpleClusterKey[K] with RedisCommandIntegerLong {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/SortedSets.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.api.sortedsets

import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis._
import redis.api.{Aggregate, Limit, SUM, ZaddOption}
import redis.protocol.RedisReply
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Strings.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.strings

import redis._
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.{RedisReply, MultiBulk, Status, RedisProtocolRequest}
import redis.api.BitOperator

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/Transactions.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.api.transactions

import redis.{RedisCommandMultiBulk, RedisCommandStatusBoolean}
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.MultiBulk

case object Multi extends RedisCommandStatusBoolean {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/api.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.api

import akka.util.ByteString
import org.apache.pekko.util.ByteString


trait Aggregate
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/geo/DistUnits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package redis.api.geo
object DistUnits{
sealed trait Measurement{
def value:String = {
this match {
this match {git add
case Meter => "m"
case Kilometer => "km"
case Mile => "mi"
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/geo/Geo.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.api.geo

import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis._
import redis.api.geo.DistUnits.Measurement
import redis.api.geo.GeoOptions.WithOption
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/redis/api/pubsub/pubsub.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.api.pubsub

import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.RedisProtocolRequest

case class Message(channel: String, data: ByteString)
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/redis/ConverterSpec.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis

import org.specs2.mutable.Specification
import akka.util.ByteString
import org.apache.pekko.util.ByteString
import redis.protocol.{Bulk, RedisReply}

case class DumbClass(s1: String, s2: String)
Expand Down
Loading