Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
8d5cbc2
@composite parameters support in RPC metadata
ghik Jun 27, 2018
77af6c5
@composite method parameters support in raw RPC traits
ghik Jun 27, 2018
bd09b68
-trailing commas
ghik Jun 27, 2018
d234e98
more -trailing commas
ghik Jun 28, 2018
7f7cf74
RPC name raw parameter is denoted by @methodName and may appear anywhere
ghik Jun 28, 2018
862ec7b
rpcNamePrefix annotation and RawRest refactor
ghik Jul 2, 2018
b646362
real method global uniqueness constraint comes back
ghik Jul 2, 2018
091cfa1
some generated code size optimizations for RPC macros
ghik Jul 3, 2018
7ce2634
WIP prototype of REST core framework
ghik Jul 3, 2018
7bb620f
commons-core: fixed support for empty request body
Jul 3, 2018
d055e1b
commons-jetty: fixed body reading
Jul 3, 2018
d7a4e80
convenience companions for REST API traits
ghik Jul 3, 2018
84d57a5
added simple test for RawRest
ghik Jul 3, 2018
269079e
added Future.unit compat extension for Scala 2.11
ghik Jul 4, 2018
8810e19
commons-jetty: refactored JettyRestHandler - now available as RestSer…
Jul 4, 2018
887329a
commons-jetty: RestServlet will now handle exceptions thrown by real …
Jul 4, 2018
976c5da
added various convenience methods for working with RPC typeclasses
ghik Jul 4, 2018
c0ef6de
replaced BodyValue with separate JsonValue and mime-type aware HttpBody
ghik Jul 4, 2018
101eeef
fixed empty content handling
ghik Jul 4, 2018
73dd4a6
cosmetic
ghik Jul 4, 2018
7fc792b
GET is now handled by separate raw method
ghik Jul 4, 2018
6529e73
minor
ghik Jul 4, 2018
2d7b102
empty body encoding for Unit
ghik Jul 4, 2018
201e50a
AsReal/Raw for HttpBody is by default based on AsReal/Raw for JsonValue
ghik Jul 4, 2018
e0d5e10
arbitrary multi-level paths independent from rpcName for REST methods
ghik Jul 4, 2018
0e2007f
rest scaladocs, introduced NamedParams instead of ListMap
ghik Jul 5, 2018
2321ce1
fixed scaladocs and error messages
ghik Jul 5, 2018
4a6de7d
added path suffixes to Path rest params
ghik Jul 6, 2018
2625e73
@defaultsToName meta annotation for annotation parameters
ghik Jul 6, 2018
89208f6
test improvement
ghik Jul 6, 2018
5517aa7
added REST server API validation to detect ambiguous paths
ghik Jul 6, 2018
697d1d6
refactored rest.scala to multiple files
ghik Jul 6, 2018
c6b6547
path pattern now holds param metadata
ghik Jul 6, 2018
205edf9
PathParamMetadata has rpcName
ghik Jul 6, 2018
27d64b0
transientDefault support for optional and named RPC parameters
ghik Jul 6, 2018
227e6d4
definalized annotations
ghik Jul 6, 2018
222819a
minor doc update
ghik Jul 6, 2018
776fe01
test fix
ghik Jul 6, 2018
0f6376c
RestClient based on Jetty HTTP client
ghik Jul 6, 2018
02f315c
more REST tests and corrections
ghik Jul 9, 2018
b2ff798
trailing comma
ghik Jul 9, 2018
7d6cabe
inter project dependencies include tests
ghik Jul 9, 2018
e0a7fe0
fixed definition of RestMetadata to have correct default param tags
ghik Jul 9, 2018
f178a17
better empty HttpBody support
ghik Jul 9, 2018
07284f4
cosmetic
ghik Jul 9, 2018
421c335
moved jetty rest implementations to rest package
ghik Jul 11, 2018
a0e7b0d
convenience apply creators in RestHandler/RestServlet/RestClient
ghik Jul 11, 2018
0f36c8c
fixed bad setting of content length
ghik Jul 11, 2018
f66791b
moved jetty rest tests to appropriate package
ghik Jul 11, 2018
d9a06bf
quickstart example in REST documentation
ghik Jul 11, 2018
d38c50d
more meaningful Opt vs Option benchmarks
ghik Jul 12, 2018
c95d81a
Merge branch 'io-refactor' into rpc-composite
ghik Jul 13, 2018
31dc351
Merge branch 'master' into rpc-composite
ghik Jul 16, 2018
cbcef62
RPC tagging reworked to allow specifying fallback tag values
ghik Jul 17, 2018
3562a93
refactored RPC macros by introducing MatchedRealSymbol
ghik Jul 17, 2018
0301bcf
fixed param uniqueness checking to exclude auxiliary raw params
ghik Jul 17, 2018
479b2b3
introduced machinery for injecting custom implicits into RPC companions
ghik Jul 17, 2018
e85ab6d
disallowed materialization of RpcMacroInstances outside of trait's file
ghik Jul 17, 2018
2746a49
refactored REST macro instances and companions out of RawRest
ghik Jul 17, 2018
7581960
cosmetic
ghik Jul 17, 2018
5c3a350
scaladoc fix
ghik Jul 17, 2018
885eeaf
changing mima config
ghik Jul 17, 2018
529b478
renaming companions
ghik Jul 17, 2018
c5afd41
simplified RpcMacroInstances machinery
ghik Jul 18, 2018
888416b
added unique param validation for REST
ghik Jul 18, 2018
6c3f69c
added missing REST implicits for Float/Double
ghik Jul 18, 2018
3622f67
identity for AsReal/AsRaw/AsRawReal is implicit
ghik Jul 18, 2018
36c1b4e
REST docs
ghik Jul 18, 2018
9aa2904
typos
ghik Jul 18, 2018
01a5ad8
FindUsages analyzer rule
ghik Jul 19, 2018
d906a50
dedicated exceptions for RPC, minor refactors
ghik Jul 19, 2018
798daf9
rest exceptions fixed
ghik Jul 19, 2018
182df94
added method metadata to REST call resolution
ghik Jul 19, 2018
51a8fa5
fixed one more exception
ghik Jul 19, 2018
bf34140
introduced Fallback for cancelling higher priority of imported implicits
ghik Jul 19, 2018
76f33ca
cosmetic finals
ghik Jul 19, 2018
f6bd2b9
REST serialization documentation
ghik Jul 19, 2018
d33ed74
more REST documentation and some helper methods
ghik Jul 19, 2018
59fdb30
table of contents fixed
ghik Jul 19, 2018
ceb4355
minor
ghik Jul 19, 2018
37b3b28
doc -> source links
ghik Jul 19, 2018
9ead1e4
decoupled REST framework from usage of Futures, updated docs
ghik Jul 20, 2018
70fe834
introduced HttpResponseType to uncouple RestMetadata from FUture
ghik Jul 23, 2018
9292d04
docs updated
ghik Jul 23, 2018
ee7c323
Merge branch 'master' into rpc-rest
ghik Jul 23, 2018
bf5b5f6
scala 2.11 bump in travis
ghik Jul 23, 2018
9611c68
cosmetic
ghik Jul 23, 2018
54f0fae
REST doctoc update
ghik Jul 23, 2018
c91b3b3
improved exception handling in REST
ghik Jul 23, 2018
0c034b3
introduced tried annotation to catch exceptions thrown by real methods
ghik Jul 24, 2018
aa59e01
Try.fold in compat extensions
ghik Jul 24, 2018
6b62f78
fixed CompatSharedExtensions
ghik Jul 24, 2018
21e6e17
refactored resolvePath and renamed RestHeaders to RestParameters
ghik Jul 25, 2018
5f9211b
doc fix
ghik Jul 25, 2018
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: scala

scala:
- 2.11.11
- 2.11.12
- 2.12.6

jdk:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
derivation for case classes and sealed hierarchies
* [RPC framework](docs/RPCFramework.md): **typesafe** RPC/proxy framework used in particular by
[Udash Framework](http://guide.udash.io/#/rpc) for client-server communication
* [REST framework](docs/REST.md) based on RPC framework
* Better enumeration support for Scala -
[`ValueEnum`](http://avsystem.github.io/scala-commons/api/com/avsystem/commons/misc/ValueEnum.html),
[`SealedEnumCompanion`](http://avsystem.github.io/scala-commons/api/com/avsystem/commons/misc/SealedEnumCompanion.html),
Expand Down
25 changes: 14 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cancelable in Global := true
val forIdeaImport = System.getProperty("idea.managed", "false").toBoolean && System.getProperty("idea.runid") == null

// for binary compatibility checking
val previousVersion = "1.27.3"
val previousCompatibleVersions = Set.empty[String]

val silencerVersion = "1.1"
val guavaVersion = "23.0"
Expand Down Expand Up @@ -100,8 +100,8 @@ val jvmCommonSettings = commonSettings ++ Seq(
libraryDependencies ++= Seq(
"org.apache.commons" % "commons-io" % commonsIoVersion % Test,
),
mimaPreviousArtifacts := {
Set(organization.value % s"${name.value}_${scalaBinaryVersion.value}" % previousVersion)
mimaPreviousArtifacts := previousCompatibleVersions.map { previousVersion =>
organization.value % s"${name.value}_${scalaBinaryVersion.value}" % previousVersion
},
)

Expand Down Expand Up @@ -192,7 +192,7 @@ lazy val `commons-macros` = project.settings(
)

lazy val `commons-core` = project
.dependsOn(`commons-macros`, `commons-annotations`)
.dependsOn(`commons-macros`, `commons-annotations` % CompileAndTest)
.settings(
jvmCommonSettings,
sourceDirsSettings(_ / "jvm"),
Expand All @@ -206,7 +206,7 @@ lazy val `commons-core` = project
lazy val `commons-core-js` = project.in(`commons-core`.base / "js")
.enablePlugins(ScalaJSPlugin)
.configure(p => if (forIdeaImport) p.dependsOn(`commons-core`) else p)
.dependsOn(`commons-macros`, `commons-annotations-js`)
.dependsOn(`commons-macros`, `commons-annotations-js` % CompileAndTest)
.settings(
jsCommonSettings,
name := (name in `commons-core`).value,
Expand All @@ -229,13 +229,16 @@ lazy val `commons-analyzer` = project
)

lazy val `commons-jetty` = project
.dependsOn(`commons-core`)
.dependsOn(`commons-core` % CompileAndTest)
.settings(
jvmCommonSettings,
libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-client" % jettyVersion,
"org.eclipse.jetty" % "jetty-server" % jettyVersion,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion,

"org.eclipse.jetty" % "jetty-servlet" % jettyVersion % Test,
"org.slf4j" % "slf4j-simple" % "1.7.25" % Test,
),
)

Expand Down Expand Up @@ -283,7 +286,7 @@ lazy val `commons-benchmark-js` = project.in(`commons-benchmark`.base / "js")
)

lazy val `commons-mongo` = project
.dependsOn(`commons-core`)
.dependsOn(`commons-core` % CompileAndTest)
.settings(
jvmCommonSettings,
libraryDependencies ++= Seq(
Expand All @@ -297,7 +300,7 @@ lazy val `commons-mongo` = project
)

lazy val `commons-kafka` = project
.dependsOn(`commons-core`)
.dependsOn(`commons-core` % CompileAndTest)
.settings(
jvmCommonSettings,
libraryDependencies ++= Seq(
Expand All @@ -306,7 +309,7 @@ lazy val `commons-kafka` = project
)

lazy val `commons-redis` = project
.dependsOn(`commons-core`)
.dependsOn(`commons-core` % CompileAndTest)
.settings(
jvmCommonSettings,
libraryDependencies ++= Seq(
Expand All @@ -318,7 +321,7 @@ lazy val `commons-redis` = project
)

lazy val `commons-spring` = project
.dependsOn(`commons-core`)
.dependsOn(`commons-core` % CompileAndTest)
.settings(
jvmCommonSettings,
libraryDependencies ++= Seq(
Expand All @@ -328,7 +331,7 @@ lazy val `commons-spring` = project
)

lazy val `commons-akka` = project
.dependsOn(`commons-core`)
.dependsOn(`commons-core` % CompileAndTest)
.settings(
jvmCommonSettings,
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait MonixRPCFramework extends RPCFramework {
override type RawRPC <: MonixRawRPC

trait MonixRawRPC { this: RawRPC =>
@multi def observe(rpcName: String)(@multi args: List[RawValue]): Observable[RawValue]
@multi def observe(@composite invocation: RawInvocation): Observable[RawValue]
}

implicit def readerBasedObservableAsReal[T: Reader]: AsReal[Observable[RawValue], Observable[T]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.avsystem.commons
package rpc.akka

import akka.util.ByteString
import com.avsystem.commons.rpc.akka.AkkaRPCFramework.RawValue
import com.avsystem.commons.rpc.akka.AkkaRPCFramework._
import com.avsystem.commons.serialization.GenCodec

/**
Expand All @@ -11,8 +11,8 @@ import com.avsystem.commons.serialization.GenCodec
private sealed trait RemoteMessage extends Serializable

private object RemoteMessage {
implicit val byteStringCodec = GenCodec.create[ByteString](input => ByteString(input.readBinary()), (output, byteString) => output.writeBinary(byteString.toArray))
implicit val rawInvocationCodec = GenCodec.materialize[RawInvocation]
implicit val byteStringCodec: GenCodec[ByteString] =
GenCodec.create[ByteString](input => ByteString(input.readBinary()), (output, byteString) => output.writeBinary(byteString.toArray))

implicit val procedureInvocationMessageCodec: GenCodec[ProcedureInvocationMessage] = GenCodec.materialize[ProcedureInvocationMessage]
implicit val functionInvocationMessageCodec: GenCodec[FunctionInvocationMessage] = GenCodec.materialize[FunctionInvocationMessage]
Expand All @@ -28,16 +28,13 @@ private object RemoteMessage {
implicit val heatBeatCodec: GenCodec[MonixProtocol.Heartbeat.type] = GenCodec.materialize[MonixProtocol.Heartbeat.type]
}

private final case class RawInvocation(rpcName: String, args: List[RawValue]) extends RemoteMessage

private sealed trait InvocationMessage extends RemoteMessage {
def getterChain: Seq[RawInvocation]
def name: String
def args: List[RawValue]
def invocation: RawInvocation
}
private final case class ProcedureInvocationMessage(name: String, args: List[RawValue], getterChain: Seq[RawInvocation]) extends InvocationMessage
private final case class FunctionInvocationMessage(name: String, args: List[RawValue], getterChain: Seq[RawInvocation]) extends InvocationMessage
private final case class ObservableInvocationMessage(name: String, args: List[RawValue], getterChain: Seq[RawInvocation]) extends InvocationMessage
private final case class ProcedureInvocationMessage(invocation: RawInvocation, getterChain: Seq[RawInvocation]) extends InvocationMessage
private final case class FunctionInvocationMessage(invocation: RawInvocation, getterChain: Seq[RawInvocation]) extends InvocationMessage
private final case class ObservableInvocationMessage(invocation: RawInvocation, getterChain: Seq[RawInvocation]) extends InvocationMessage

private sealed trait InvocationResult extends RemoteMessage
private final case class InvocationSuccess(value: RawValue) extends InvocationResult
Expand All @@ -52,4 +49,4 @@ private object MonixProtocol {
case object StreamCompleted extends RemoteMessage

case object Heartbeat extends RemoteMessage
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package rpc.akka.client
import akka.actor.ActorSystem
import akka.pattern.ask
import akka.util.Timeout
import com.avsystem.commons.rpc.akka.AkkaRPCFramework.{RawRPC, RawValue}
import com.avsystem.commons.rpc.akka.AkkaRPCFramework._
import com.avsystem.commons.rpc.akka._
import monix.execution.Cancelable
import monix.reactive.{Observable, OverflowStrategy}
Expand All @@ -14,12 +14,12 @@ import monix.reactive.{Observable, OverflowStrategy}
*/
private[akka] final class ClientRawRPC(config: AkkaRPCClientConfig, getterChain: Seq[RawInvocation] = Nil)(implicit system: ActorSystem) extends AkkaRPCFramework.RawRPC {

override def fire(rpcName: String)(args: List[RawValue]): Unit = {
system.actorSelection(config.serverPath) ! ProcedureInvocationMessage(rpcName, args, getterChain)
override def fire(invocation: RawInvocation): Unit = {
system.actorSelection(config.serverPath) ! ProcedureInvocationMessage(invocation, getterChain)
}
override def call(rpcName: String)(args: List[RawValue]): Future[RawValue] = {
override def call(invocation: RawInvocation): Future[RawValue] = {
implicit val timeout: Timeout = Timeout(config.functionCallTimeout)
val future = system.actorSelection(config.serverPath) ? FunctionInvocationMessage(rpcName, args, getterChain)
val future = system.actorSelection(config.serverPath) ? FunctionInvocationMessage(invocation, getterChain)

import com.avsystem.commons.concurrent.RunNowEC.Implicits.executionContext

Expand All @@ -29,13 +29,13 @@ private[akka] final class ClientRawRPC(config: AkkaRPCClientConfig, getterChain:
case value => Future.failed(new IllegalStateException(s"Illegal message type. Should be InvocationResult, but received value was: $value"))
}
}
override def get(rpcName: String)(args: List[RawValue]): RawRPC =
new ClientRawRPC(config, getterChain :+ RawInvocation(rpcName, args))
override def get(invocation: RawInvocation): RawRPC =
new ClientRawRPC(config, getterChain :+ invocation)

override def observe(rpcName: String)(args: List[RawValue]): Observable[RawValue] = {
override def observe(invocation: RawInvocation): Observable[RawValue] = {
Observable.create(OverflowStrategy.Unbounded) { s =>
val actor = system.actorOf(MonixClientActor.props(s, config))
actor ! ObservableInvocationMessage(rpcName, args, getterChain)
actor ! ObservableInvocationMessage(invocation, getterChain)
Cancelable.empty // TODO implement proper canceling
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ final class RemoteMessageSerializer extends Serializer {
case c if c == classOf[ProcedureInvocationMessage] => GenCodec.read[ProcedureInvocationMessage](input)
case c if c == classOf[FunctionInvocationMessage] => GenCodec.read[FunctionInvocationMessage](input)
case c if c == classOf[ObservableInvocationMessage] => GenCodec.read[ObservableInvocationMessage](input)
case c if c == classOf[RawInvocation] => GenCodec.read[RawInvocation](input)
case c if c == classOf[InvocationSuccess] => GenCodec.read[InvocationSuccess](input)
case c if c == classOf[InvocationFailure] => GenCodec.read[InvocationFailure](input)
case c if c == MonixProtocol.Continue.getClass => GenCodec.read[MonixProtocol.Continue.type](input)
Expand All @@ -46,7 +45,6 @@ final class RemoteMessageSerializer extends Serializer {
case m: ProcedureInvocationMessage => GenCodec.write(output, m)
case m: FunctionInvocationMessage => GenCodec.write(output, m)
case m: ObservableInvocationMessage => GenCodec.write(output, m)
case m: RawInvocation => GenCodec.write(output, m)
case m: InvocationSuccess => GenCodec.write(output, m)
case m: InvocationFailure => GenCodec.write(output, m)
case MonixProtocol.Continue => GenCodec.write(output, MonixProtocol.Continue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@ import akka.actor.{Actor, ActorLogging, Props}
import akka.pattern.{AskTimeoutException, ask}
import akka.util.Timeout
import com.avsystem.commons.concurrent.RunNowEC
import com.avsystem.commons.rpc.akka.AkkaRPCFramework._
import com.avsystem.commons.rpc.akka._
import monix.execution.{Ack, Scheduler}
import monix.reactive.Observable

/**
* @author Wojciech Milewski
*/
private final class ServerActor(rawRPC: AkkaRPCFramework.RawRPC, config: AkkaRPCServerConfig) extends Actor with ActorLogging {
private final class ServerActor(rawRPC: RawRPC, config: AkkaRPCServerConfig) extends Actor with ActorLogging {

override def receive: Receive = {
case msg@ProcedureInvocationMessage(name, argLists, getterChain) =>
resolveRpc(msg).fire(name)(argLists)
case msg@FunctionInvocationMessage(name, argLists, getterChain) =>
case ProcedureInvocationMessage(invocation, getterChain) =>
resolveRpc(getterChain).fire(invocation)
case FunctionInvocationMessage(invocation, getterChain) =>
val s = sender()
resolveRpc(msg).call(name)(argLists).onCompleteNow {
resolveRpc(getterChain).call(invocation).onCompleteNow {
case Success(value) => s ! InvocationSuccess(value)
case Failure(e) =>
logError(e, name)
logError(e, invocation.rpcName)
s ! InvocationFailure(e.getClass.getCanonicalName, e.getMessage)
}
case msg@ObservableInvocationMessage(name, argLists, getterChain) =>
case ObservableInvocationMessage(invocation, getterChain) =>
implicit val scheduler: Scheduler = Scheduler(RunNowEC)
implicit val timeout: Timeout = Timeout(config.observableAckTimeout)
val s = sender()
Expand All @@ -36,7 +37,7 @@ private final class ServerActor(rawRPC: AkkaRPCFramework.RawRPC, config: AkkaRPC
Ack.Continue
}

resolveRpc(msg).observe(name)(argLists).subscribe(
resolveRpc(getterChain).observe(invocation).subscribe(
value => {
val result = s ? InvocationSuccess(value)
result.mapTo[MonixProtocol.RemoteAck].map {
Expand All @@ -53,7 +54,7 @@ private final class ServerActor(rawRPC: AkkaRPCFramework.RawRPC, config: AkkaRPC
},
e => {
heartbeat.cancel()
logError(e, name)
logError(e, invocation.rpcName)
s ! InvocationFailure(e.getClass.getCanonicalName, e.getMessage)
},
() => {
Expand All @@ -63,8 +64,8 @@ private final class ServerActor(rawRPC: AkkaRPCFramework.RawRPC, config: AkkaRPC
)
}

private def resolveRpc(msg: InvocationMessage) =
rawRPC.resolveGetterChain(msg.getterChain.map(r => AkkaRPCFramework.RawInvocation(r.rpcName, r.args)).toList)
private def resolveRpc(getterChain: Seq[RawInvocation]): RawRPC =
rawRPC.resolveGetterChain(getterChain)

private def logError(e: Throwable, methodName: String): Unit = {
log.error(e,
Expand All @@ -76,5 +77,5 @@ private final class ServerActor(rawRPC: AkkaRPCFramework.RawRPC, config: AkkaRPC
}

private[akka] object ServerActor {
def props(rawRPC: AkkaRPCFramework.RawRPC, config: AkkaRPCServerConfig): Props = Props(new ServerActor(rawRPC, config))
def props(rawRPC: RawRPC, config: AkkaRPCServerConfig): Props = Props(new ServerActor(rawRPC, config))
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import scala.concurrent.duration._
* @author Wojciech Milewski
*/
abstract class AkkaRPCFrameworkTest(
serverSystem: ActorSystem,
clientSystem: ActorSystem,
serverSystemPath: Option[String] = None)
extends FlatSpec with RPCFrameworkTest with ProcedureRPCTest with FunctionRPCTest with GetterRPCTest with ObservableRPCTest with BeforeAndAfterAll {
serverSystem: ActorSystem, clientSystem: ActorSystem, serverSystemPath: Option[String] = None)
extends FlatSpec with RPCFrameworkTest with ProcedureRPCTest with FunctionRPCTest with GetterRPCTest with ObservableRPCTest
with BeforeAndAfterAll {

/**
* Servers as identifier supplier for each test case to allow tests parallelization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ trait RPCFrameworkTest extends FlatSpecLike with Matchers with MockitoSugar with

import RPCFrameworkTest._

val callTimeout = 200.millis
val callTimeout: FiniteDuration = 200.millis

override implicit val patienceConfig: PatienceConfig = PatienceConfig(timeout = Span.convertDurationToSpan(3.seconds))
override implicit val patienceConfig: PatienceConfig =
PatienceConfig(timeout = Span.convertDurationToSpan(10.seconds))

/**
* Run tests with connection between client and server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,45 @@ import scala.tools.nsc.{Global, Phase}

final class AnalyzerPlugin(val global: Global) extends Plugin { plugin =>

val rules = List[AnalyzerRule[global.type]](
new ImportJavaUtil[global.type](global),
new VarargsAtLeast[global.type](global),
new CheckMacroPrivate[global.type](global),
new ExplicitGenerics[global.type](global),
new ValueEnumExhaustiveMatch[global.type](global),
new ShowAst[global.type](global)
)
val rulesByName = rules.map(r => (r.name, r)).toMap

override def init(options: List[String], error: String => Unit): Boolean = {
options.foreach { option =>
val level = option.charAt(0) match {
case '-' => Level.Off
case '*' => Level.Info
case '+' => Level.Error
case _ => Level.Warn
}
val name = if (level != Level.Warn) option.drop(1) else option
if (name == "_") {
val nameArg = if (level != Level.Warn) option.drop(1) else option
if (nameArg == "_") {
rules.foreach(_.level = level)
} else rulesByName.get(name) match {
case Some(rule) => rule.level = level
case None => error(s"Unrecognized AVS analyzer rule: $name")
} else {
val (name, arg) = nameArg.split(":", 2) match {
case Array(n, a) => (n, a)
case Array(n) => (n, null)
}
rulesByName.get(name) match {
case Some(rule) =>
rule.level = level
rule.argument = arg
case None =>
error(s"Unrecognized AVS analyzer rule: $name")
}
}
}
true
}

private lazy val rules = List[AnalyzerRule[global.type]](
new ImportJavaUtil[global.type](global),
new VarargsAtLeast[global.type](global),
new CheckMacroPrivate[global.type](global),
new ExplicitGenerics[global.type](global),
new ValueEnumExhaustiveMatch[global.type](global),
new ShowAst[global.type](global),
new FindUsages[global.type](global)
)
private lazy val rulesByName = rules.map(r => (r.name, r)).toMap

val name = "AVSystemAnalyzer"
val description = "AVSystem custom Scala static analyzer"
val components: List[PluginComponent] = List(component)
Expand Down
Loading