Skip to content

Commit e14ed08

Browse files
authored
Merge pull request #202 from dskrvk/remove_pubsub0204
Remove PubSubServer and dependency on Akka
2 parents 9ba10dd + 083a4df commit e14ed08

File tree

7 files changed

+69
-325
lines changed

7 files changed

+69
-325
lines changed

build.sbt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name := "RedisClient"
2+
3+
lazy val redisClient = (project in file(".")).settings(coreSettings : _*)
4+
5+
lazy val commonSettings: Seq[Setting[_]] = Seq(
6+
organization := "net.debasishg",
7+
version := "3.6",
8+
scalaVersion := "2.11.12",
9+
crossScalaVersions := Seq("2.12.4", "2.11.12", "2.10.7"),
10+
11+
scalacOptions in Compile ++= Seq( "-unchecked", "-feature", "-language:postfixOps", "-deprecation" ),
12+
13+
resolvers ++= Seq(
14+
"typesafe repo" at "http://repo.typesafe.com/typesafe/releases/"
15+
)
16+
)
17+
18+
lazy val coreSettings = commonSettings ++ Seq(
19+
name := "RedisClient",
20+
libraryDependencies ++= Seq(
21+
"commons-pool" % "commons-pool" % "1.6",
22+
"org.slf4j" % "slf4j-api" % "1.7.25",
23+
"org.slf4j" % "slf4j-log4j12" % "1.7.25" % "provided",
24+
"log4j" % "log4j" % "1.2.17" % "provided",
25+
"junit" % "junit" % "4.12" % "test",
26+
"org.scalatest" %% "scalatest" % "3.0.4" % "test"),
27+
28+
parallelExecution in Test := false,
29+
publishTo := version { (v: String) =>
30+
val nexus = "https://oss.sonatype.org/"
31+
if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
32+
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
33+
}.value,
34+
credentials += Credentials(Path.userHome / ".sbt" / "sonatype.credentials"),
35+
publishMavenStyle := true,
36+
publishArtifact in Test := false,
37+
pomIncludeRepository := { repo => false },
38+
pomExtra := (
39+
<url>https://github.com/debasishg/scala-redis</url>
40+
<licenses>
41+
<license>
42+
<name>Apache 2.0 License</name>
43+
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
44+
<distribution>repo</distribution>
45+
</license>
46+
</licenses>
47+
<scm>
48+
<url>git@github.com:debasishg/scala-redis.git</url>
49+
<connection>scm:git:git@github.com:debasishg/scala-redis.git</connection>
50+
</scm>
51+
<developers>
52+
<developer>
53+
<id>debasishg</id>
54+
<name>Debasish Ghosh</name>
55+
<url>http://debasishg.blogspot.com</url>
56+
</developer>
57+
</developers>),
58+
unmanagedResources in Compile += baseDirectory.map( _ / "LICENSE" ).value
59+
)

project/ScalaRedisProject.scala

Lines changed: 0 additions & 72 deletions
This file was deleted.

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.17
1+
sbt.version=1.1.0

src/main/scala/com/redis/PubSubServer.scala

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/test/resources/application.conf

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/test/scala/com/redis/Patterns.scala

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package com.redis
22

33
import serialization._
4-
import scala.concurrent.{ ExecutionContext, Await, Future }
4+
import scala.concurrent.{ Await, Future }
55
import scala.concurrent.duration._
6-
import akka.actor.ActorSystem
76

87
/**
98
* Implementing some of the common patterns like scatter/gather, which can benefit from
@@ -25,25 +24,24 @@ object Patterns {
2524
def listPush(count: Int, key: String)(implicit clients: RedisClientPool) = {
2625
clients.withClient { client =>
2726
(1 to count) foreach {i => client.rpush(key, i)}
28-
assert(client.llen(key) == Some(count))
27+
assert(client.llen(key).contains(count))
2928
}
3029
key
3130
}
3231

3332
def listPop(count: Int, key: String)(implicit clients: RedisClientPool) = {
34-
implicit val parseInt = Parse[Long](new String(_).toLong)
33+
implicit val parseInt: Parse[Long] = Parse[Long](new String(_).toLong)
3534
clients.withClient { client =>
36-
val list = (1 to count) map {i => client.lpop[Long](key).get}
37-
assert(client.llen(key) == Some(0))
35+
val list = (1 to count) map {_ => client.lpop[Long](key).get}
36+
assert(client.llen(key).contains(0))
3837
list.sum
3938
}
4039
}
4140

4241
// set up Executors
43-
val system = ActorSystem("ScatterGatherSystem")
44-
import system.dispatcher
42+
import scala.concurrent.ExecutionContext.Implicits.global
4543

46-
val timeout = 5 minutes
44+
val timeout: Duration = 5 minutes
4745

4846
private[this] def flow[A](noOfRecipients: Int, opsPerClient: Int, keyPrefix: String,
4947
fn: (Int, String) => A) = {
@@ -69,7 +67,7 @@ object Patterns {
6967
val allPops = Future.sequence(futurePops)
7068
allPops map {members => members.sum}
7169
}
72-
Await.result(allSum, timeout).asInstanceOf[Long]
70+
Await.result(allSum, timeout)
7371
}
7472

7573
// scatter across clietns and gather the first future to complete
@@ -84,6 +82,6 @@ object Patterns {
8482
val firstSum = firstPush map {key =>
8583
listPop(opsPerClient, key)
8684
}
87-
Await.result(firstSum, timeout).asInstanceOf[Int]
85+
Await.result(firstSum, timeout)
8886
}
8987
}

0 commit comments

Comments
 (0)