Skip to content
Permalink
Browse files

Add refined types to configuration (#120)

* Add refined types to configuration

* Downgrade SBT Web ScalaJS

* Add refined types to the configuration test
  • Loading branch information...
A. Alonso Dominguez
A. Alonso Dominguez committed Sep 8, 2017
1 parent 68ff5b0 commit 4ae4113ed28137a70af99b55544b2a1da33b8f56
Showing with 2,406 additions and 2,880 deletions.
  1. +0 −4 scalafmt.conf → .scalafmt.conf
  2. +19 −24 build.sbt
  3. +2 −4 client/js/src/main/scala/io/quckoo/client/http/dom/EventSourceSubscriber.scala
  4. +2 −3 client/js/src/main/scala/io/quckoo/client/http/dom/HttpDOMBackend.scala
  5. +1 −1 client/js/src/main/scala/io/quckoo/client/http/dom/package.scala
  6. +44 −50 client/jvm/src/main/scala/io/quckoo/client/http/akka/HttpAkkaBackend.scala
  7. +4 −3 client/jvm/src/main/scala/io/quckoo/client/http/akka/HttpAkkaQuckooClient.scala
  8. +21 −23 client/jvm/src/main/scala/io/quckoo/client/tcp/QuckooTcpClient.scala
  9. +1 −2 client/jvm/src/test/scala/io/quckoo/client/http/MockServer.scala
  10. +45 −57 client/jvm/src/test/scala/io/quckoo/client/http/akka/AkkaHttpBackendSpec.scala
  11. +3 −3 console/src/main/scala/io/quckoo/console/ConsoleRoute.scala
  12. +3 −6 console/src/main/scala/io/quckoo/console/boot/Boot.scala
  13. +4 −7 console/src/main/scala/io/quckoo/console/boot/ConsoleApp.scala
  14. +1 −2 console/src/main/scala/io/quckoo/console/boot/ConsoleRouter.scala
  15. +8 −6 console/src/main/scala/io/quckoo/console/components/Button.scala
  16. +23 −38 console/src/main/scala/io/quckoo/console/components/CodeEditor.scala
  17. +13 −15 console/src/main/scala/io/quckoo/console/components/CoproductSelect.scala
  18. +2 −4 console/src/main/scala/io/quckoo/console/components/DateTimeDisplay.scala
  19. +18 −19 console/src/main/scala/io/quckoo/console/components/FiniteDurationInput.scala
  20. +18 −21 console/src/main/scala/io/quckoo/console/components/Icon.scala
  21. +594 −594 console/src/main/scala/io/quckoo/console/components/Icons.scala
  22. +16 −19 console/src/main/scala/io/quckoo/console/components/Input.scala
  23. +11 −12 console/src/main/scala/io/quckoo/console/components/Modal.scala
  24. +7 −6 console/src/main/scala/io/quckoo/console/components/NavBar.scala
  25. +15 −14 console/src/main/scala/io/quckoo/console/components/Notification.scala
  26. +30 −24 console/src/main/scala/io/quckoo/console/components/NotificationContainer.scala
  27. +6 −4 console/src/main/scala/io/quckoo/console/components/Panel.scala
  28. +44 −42 console/src/main/scala/io/quckoo/console/components/Table.scala
  29. +8 −7 console/src/main/scala/io/quckoo/console/components/TextArea.scala
  30. +5 −8 console/src/main/scala/io/quckoo/console/components/ValidatedInput.scala
  31. +13 −13 console/src/main/scala/io/quckoo/console/components/package.scala
  32. +2 −4 console/src/main/scala/io/quckoo/console/core/ActionSubscriber.scala
  33. +1 −2 console/src/main/scala/io/quckoo/console/core/AuthHandler.scala
  34. +5 −11 console/src/main/scala/io/quckoo/console/core/ConsoleCircuit.scala
  35. +1 −2 console/src/main/scala/io/quckoo/console/core/ConsoleOps.scala
  36. +3 −6 console/src/main/scala/io/quckoo/console/core/Effects.scala
  37. +2 −4 console/src/main/scala/io/quckoo/console/core/ErrorProcessor.scala
  38. +6 −10 console/src/main/scala/io/quckoo/console/core/LoginProcessor.scala
  39. +19 −31 console/src/main/scala/io/quckoo/console/core/messages.scala
  40. +1 −2 console/src/main/scala/io/quckoo/console/core/package.scala
  41. +31 −22 console/src/main/scala/io/quckoo/console/dashboard/ClusterView.scala
  42. +2 −5 console/src/main/scala/io/quckoo/console/dashboard/DashboardHandler.scala
  43. +2 −2 console/src/main/scala/io/quckoo/console/dashboard/DashboardPage.scala
  44. +1 −2 console/src/main/scala/io/quckoo/console/dashboard/NodeList.scala
  45. +1 −6 console/src/main/scala/io/quckoo/console/dashboard/package.scala
  46. +1 −2 console/src/main/scala/io/quckoo/console/layout/ClockWidget.scala
  47. +1 −1 console/src/main/scala/io/quckoo/console/layout/ContextStyle.scala
  48. +1 −2 console/src/main/scala/io/quckoo/console/layout/Footer.scala
  49. +7 −14 console/src/main/scala/io/quckoo/console/layout/Layout.scala
  50. +32 −30 console/src/main/scala/io/quckoo/console/layout/LookAndFeel.scala
  51. +38 −39 console/src/main/scala/io/quckoo/console/layout/Navigation.scala
  52. +1 −1 console/src/main/scala/io/quckoo/console/libs/BootstrapJQuery.scala
  53. +1 −2 console/src/main/scala/io/quckoo/console/libs/BootstrapNotify.scala
  54. +5 −5 console/src/main/scala/io/quckoo/console/libs/codemirror/ChangeEvent.scala
  55. +14 −16 console/src/main/scala/io/quckoo/console/libs/codemirror/CodeMirror.scala
  56. +1 −1 console/src/main/scala/io/quckoo/console/libs/codemirror/CodeMirrorReact.scala
  57. +1 −1 console/src/main/scala/io/quckoo/console/libs/codemirror/LineHandle.scala
  58. +1 −1 console/src/main/scala/io/quckoo/console/libs/codemirror/package.scala
  59. +10 −16 console/src/main/scala/io/quckoo/console/log/LogDisplay.scala
  60. +3 −5 console/src/main/scala/io/quckoo/console/log/model.scala
  61. +29 −32 console/src/main/scala/io/quckoo/console/registry/ArtifactInput.scala
  62. +17 −19 console/src/main/scala/io/quckoo/console/registry/JarJobPackageInput.scala
  63. +32 −33 console/src/main/scala/io/quckoo/console/registry/JobForm.scala
  64. +13 −19 console/src/main/scala/io/quckoo/console/registry/JobPackageSelect.scala
  65. +3 −7 console/src/main/scala/io/quckoo/console/registry/JobSelect.scala
  66. +37 −39 console/src/main/scala/io/quckoo/console/registry/JobSpecList.scala
  67. +6 −6 console/src/main/scala/io/quckoo/console/registry/RegistryHandler.scala
  68. +1 −2 console/src/main/scala/io/quckoo/console/registry/RegistryPage.scala
  69. +16 −21 console/src/main/scala/io/quckoo/console/registry/ShellScriptPackageInput.scala
  70. +2 −1 console/src/main/scala/io/quckoo/console/registry/package.scala
  71. +4 −5 console/src/main/scala/io/quckoo/console/scheduler/AfterTriggerInput.scala
  72. +7 −7 console/src/main/scala/io/quckoo/console/scheduler/AtTriggerInput.scala
  73. +12 −11 console/src/main/scala/io/quckoo/console/scheduler/CronTriggerInput.scala
  74. +18 −19 console/src/main/scala/io/quckoo/console/scheduler/EveryTriggerInput.scala
  75. +39 −35 console/src/main/scala/io/quckoo/console/scheduler/ExecutionParameterList.scala
  76. +41 −41 console/src/main/scala/io/quckoo/console/scheduler/ExecutionPlanForm.scala
  77. +32 −42 console/src/main/scala/io/quckoo/console/scheduler/ExecutionPlanList.scala
  78. +10 −12 console/src/main/scala/io/quckoo/console/scheduler/ExecutionPlanPreview.scala
  79. +4 −7 console/src/main/scala/io/quckoo/console/scheduler/ExecutionPlansHandler.scala
  80. +5 −7 console/src/main/scala/io/quckoo/console/scheduler/ExecutionTimeoutInput.scala
  81. +5 −10 console/src/main/scala/io/quckoo/console/scheduler/SchedulerHandler.scala
  82. +4 −5 console/src/main/scala/io/quckoo/console/scheduler/SchedulerPage.scala
  83. +2 −5 console/src/main/scala/io/quckoo/console/scheduler/TaskExecutionList.scala
  84. +2 −4 console/src/main/scala/io/quckoo/console/scheduler/TasksHandler.scala
  85. +10 −26 console/src/main/scala/io/quckoo/console/scheduler/TriggerSelect.scala
  86. +8 −12 console/src/main/scala/io/quckoo/console/scheduler/package.scala
  87. +11 −14 console/src/main/scala/io/quckoo/console/security/LoginForm.scala
  88. +4 −8 console/src/main/scala/io/quckoo/console/security/LoginPage.scala
  89. +1 −2 console/src/main/scala/io/quckoo/console/validation/ValidatedField.scala
  90. +3 −3 console/src/test/scala/io/quckoo/console/components/FiniteDurationInputTest.scala
  91. +4 −5 console/src/test/scala/io/quckoo/console/components/FiniteDurationInputTestDsl.scala
  92. +29 −27 console/src/test/scala/io/quckoo/console/components/InputTest.scala
  93. +2 −1 console/src/test/scala/io/quckoo/console/components/NavBarTest.scala
  94. +2 −4 console/src/test/scala/io/quckoo/console/components/TextAreaTestIgnore.scala
  95. +1 −2 console/src/test/scala/io/quckoo/console/scheduler/CronTriggerInputTest.scala
  96. +2 −4 console/src/test/scala/io/quckoo/console/scheduler/CronTriggerInputTestDsl.scala
  97. +2 −2 console/src/test/scala/io/quckoo/console/security/LoginObserver.scala
  98. +8 −11 console/src/test/scala/io/quckoo/console/security/LoginTest.scala
  99. +3 −7 console/src/test/scala/io/quckoo/console/security/LoginTestDsl.scala
  100. +1 −5 console/src/test/scala/io/quckoo/console/test/ConsoleTestExports.scala
  101. +2 −3 examples/producers/src/main/scala/io/quckoo/examples/ExamplesMain.scala
  102. +12 −14 examples/producers/src/main/scala/io/quckoo/examples/parameters/PowerOfNActor.scala
  103. +18 −26 master/src/main/scala/io/quckoo/cluster/QuckooFacade.scala
  104. +1 −1 master/src/main/scala/io/quckoo/cluster/QuckooRoles.scala
  105. +5 −8 master/src/main/scala/io/quckoo/cluster/boot/Boot.scala
  106. +5 −4 master/src/main/scala/io/quckoo/cluster/boot/CliOptions.scala
  107. +12 −6 master/src/main/scala/io/quckoo/cluster/config/model.scala
  108. +11 −9 master/src/main/scala/io/quckoo/cluster/config/package.scala
  109. +4 −8 master/src/main/scala/io/quckoo/cluster/core/Auth.scala
  110. +26 −30 master/src/main/scala/io/quckoo/cluster/core/QuckooGuardian.scala
  111. +1 −6 master/src/main/scala/io/quckoo/cluster/core/QuckooServer.scala
  112. +2 −4 master/src/main/scala/io/quckoo/cluster/core/Topic.scala
  113. +8 −19 master/src/main/scala/io/quckoo/cluster/core/TopicConsumer.scala
  114. +1 −3 master/src/main/scala/io/quckoo/cluster/core/UserAuthenticator.scala
  115. +10 −18 master/src/main/scala/io/quckoo/cluster/http/AuthDirectives.scala
  116. +5 −16 master/src/main/scala/io/quckoo/cluster/http/HttpRouter.scala
  117. +1 −1 master/src/main/scala/io/quckoo/cluster/http/StaticResources.scala
  118. +3 −5 master/src/main/scala/io/quckoo/cluster/http/TimeoutDirectives.scala
  119. +5 −7 master/src/main/scala/io/quckoo/cluster/http/package.scala
  120. +1 −2 master/src/main/scala/io/quckoo/cluster/journal/QuckooProductionJournal.scala
  121. +5 −8 master/src/main/scala/io/quckoo/cluster/registry/PersistentJob.scala
  122. +13 −18 master/src/main/scala/io/quckoo/cluster/registry/Registration.scala
  123. +11 −22 master/src/main/scala/io/quckoo/cluster/registry/Registry.scala
  124. +1 −2 master/src/main/scala/io/quckoo/cluster/registry/RegistryHttpRouter.scala
  125. +55 −87 master/src/main/scala/io/quckoo/cluster/scheduler/ExecutionDriver.scala
  126. +34 −39 master/src/main/scala/io/quckoo/cluster/scheduler/ExecutionLifecycle.scala
  127. +36 −67 master/src/main/scala/io/quckoo/cluster/scheduler/Scheduler.scala
  128. +2 −3 master/src/main/scala/io/quckoo/cluster/scheduler/SchedulerHttpRouter.scala
  129. +1 −1 master/src/main/scala/io/quckoo/cluster/scheduler/SchedulerTagEventAdapter.scala
  130. +33 −45 master/src/main/scala/io/quckoo/cluster/scheduler/TaskQueue.scala
  131. +6 −11 master/src/main/scala/io/quckoo/cluster/scheduler/TaskQueueMonitor.scala
  132. +7 −3 master/src/test/scala/io/quckoo/cluster/config/ClusterSettingsSpec.scala
  133. +2 −3 master/src/test/scala/io/quckoo/cluster/core/LocalTopicConsumerSpec.scala
  134. +1 −2 master/src/test/scala/io/quckoo/cluster/core/PubSubTopicConsumerSpec.scala
  135. +1 −2 master/src/test/scala/io/quckoo/cluster/journal/QuckooTestJournal.scala
  136. +7 −14 master/src/test/scala/io/quckoo/cluster/registry/PersistentJobSpec.scala
  137. +9 −11 master/src/test/scala/io/quckoo/cluster/registry/RegistryHttpRouterSpec.scala
  138. +6 −6 master/src/test/scala/io/quckoo/cluster/registry/RegistrySpec.scala
  139. +29 −56 master/src/test/scala/io/quckoo/cluster/scheduler/ExecutionDriverSpec.scala
  140. +83 −77 master/src/test/scala/io/quckoo/cluster/scheduler/ExecutionLifecycleSpec.scala
  141. +14 −18 master/src/test/scala/io/quckoo/cluster/scheduler/SchedulerHttpRouterSpec.scala
  142. +22 −38 master/src/test/scala/io/quckoo/cluster/scheduler/SchedulerSpec.scala
  143. +29 −33 master/src/test/scala/io/quckoo/cluster/scheduler/TaskQueueSpec.scala
  144. +1 −2 master/src/test/scala/io/quckoo/testkit/QuckooActorClusterSuite.scala
  145. +7 −5 project/Dependencies.scala
  146. +2 −2 project/plugins.sbt
  147. +2 −4 shared/src/main/scala/io/quckoo/cluster/net/package.scala
  148. +2 −4 shared/src/main/scala/io/quckoo/cluster/pattern/package.scala
  149. +6 −9 shared/src/main/scala/io/quckoo/cluster/protocol/messages.scala
  150. +15 −0 shared/src/main/scala/io/quckoo/config/package.scala
  151. +1 −6 shared/src/main/scala/io/quckoo/reflect/ArtifactClassLoader.scala
  152. +3 −4 shared/src/main/scala/io/quckoo/reflect/ReflectOp.scala
  153. +3 −3 shared/src/main/scala/io/quckoo/reflect/Reflector.scala
  154. +3 −3 shared/src/main/scala/io/quckoo/reflect/ReflectorInterpreter.scala
  155. +2 −5 shared/src/main/scala/io/quckoo/reflect/javareflect/JavaReflector.scala
  156. +1 −2 shared/src/main/scala/io/quckoo/reflect/ops.scala
  157. +6 −5 shared/src/main/scala/io/quckoo/resolver/Patterns.scala
  158. +14 −21 shared/src/main/scala/io/quckoo/resolver/Repository.scala
  159. +2 −1 shared/src/main/scala/io/quckoo/resolver/Resolver.scala
  160. +2 −4 shared/src/main/scala/io/quckoo/resolver/ResolverInterpreter.scala
  161. +9 −14 shared/src/main/scala/io/quckoo/resolver/ivy/IvyConfiguration.scala
  162. +82 −94 shared/src/main/scala/io/quckoo/resolver/ivy/IvyResolver.scala
  163. +7 −11 shared/src/main/scala/io/quckoo/resolver/ivy/package.scala
  164. +1 −1 shared/src/main/scala/io/quckoo/resolver/package.scala
  165. +2 −2 shared/src/test/scala/io/quckoo/reflect/javareflect/JavaReflectorSpec.scala
  166. +2 −1 shared/src/test/scala/io/quckoo/resolver/ArtifactClassLoaderSpec.scala
  167. +1 −1 shared/src/test/scala/io/quckoo/resolver/config/IvyConfigSpec.scala
  168. +1 −4 test-support/jvm/src/main/scala/io/quckoo/testkit/QuckooActorSuite.scala
  169. +1 −1 util/js/src/main/scala/io/quckoo/md5/SparkMD5.scala
  170. +1 −1 util/js/src/test/scala/io/quckoo/md5/JsMD5Spec.scala
  171. +1 −1 util/jvm/src/main/scala/io/quckoo/md5/MD5_jvm.scala
  172. +1 −1 util/jvm/src/test/scala/io/quckoo/md5/JvmMD5Spec.scala
  173. +4 −8 worker/src/main/scala/io/quckoo/worker/boot/Boot.scala
  174. +4 −3 worker/src/main/scala/io/quckoo/worker/boot/CliOptions.scala
  175. +9 −8 worker/src/main/scala/io/quckoo/worker/config/package.scala
  176. +2 −2 worker/src/main/scala/io/quckoo/worker/core/TaskExecutor.scala
  177. +2 −1 worker/src/main/scala/io/quckoo/worker/core/TaskExecutorProvider.scala
  178. +7 −7 worker/src/main/scala/io/quckoo/worker/core/Worker.scala
  179. +4 −6 worker/src/main/scala/io/quckoo/worker/executor/DefaultTaskExecutorProvider.scala
  180. +11 −14 worker/src/main/scala/io/quckoo/worker/executor/JarTaskExecutor.scala
  181. +3 −3 worker/src/main/scala/io/quckoo/worker/executor/ProcessRunner.scala
  182. +3 −11 worker/src/main/scala/io/quckoo/worker/executor/ShellTaskExecutor.scala
  183. +9 −18 worker/src/test/scala/io/quckoo/worker/core/WorkerSpec.scala
  184. +9 −14 worker/src/test/scala/io/quckoo/worker/executor/JarTaskExecutorSpec.scala
  185. +1 −1 worker/src/test/scala/io/quckoo/worker/executor/ProcessRunnerSpec.scala
  186. +10 −14 worker/src/test/scala/io/quckoo/worker/executor/ShellTaskExecutorSpec.scala
@@ -1,10 +1,6 @@
style = defaultWithAlign
maxColumn = 100

project {
excludeFilters = [ "*.sbt" ]
}

align {
openParenCallSite = false
}
@@ -11,21 +11,22 @@ inThisBuild(
Seq(
scalaVersion := "2.12.3",
parallelExecution := false,
scalafmtVersion := "1.2.0",
scalafmtVersion := "1.1.0",
scalafmtOnCompile := true
))
)
)

lazy val commonSettings = Seq(
licenses += ("Apache-2.0", url(
"https://www.apache.org/licenses/LICENSE-2.0.txt")),
licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.txt")),
organization := "io.quckoo",
organizationName := "A. Alonso Dominguez",
startYear := Some(2015),
scmInfo := Some(
ScmInfo(
url("https://www.github.com/alonsodomin/quckoo"),
"scm:git:git@github.com:alonsodomin/quckoo.git"
)),
)
),
scalacOptions ++= Seq(
"-encoding",
"UTF-8",
@@ -61,8 +62,7 @@ lazy val commonJsSettings = Seq(
scalaJSStage in Test := FastOptStage,
jsEnv in Test := PhantomJSEnv().value,
// batch mode decreases the amount of memory needed to compile scala.js code
scalaJSOptimizerOptions := scalaJSOptimizerOptions.value.withBatchMode(
botBuild.value)
scalaJSOptimizerOptions := scalaJSOptimizerOptions.value.withBatchMode(botBuild.value)
)

lazy val scoverageSettings = Seq(
@@ -92,8 +92,8 @@ lazy val publishSettings = Seq(
new RuleTransformer(new RewriteRule {
override def transform(node: xml.Node): Seq[xml.Node] = node match {
case e: xml.Elem
if e.label == "dependency" && e.child.exists(child =>
child.label == "groupId" && child.text == "org.scoverage") =>
if e.label == "dependency" && e.child
.exists(child => child.label == "groupId" && child.text == "org.scoverage") =>
Nil
case _ => Seq(node)
}
@@ -112,10 +112,9 @@ lazy val publishSettings = Seq(
lazy val releaseSettings = {
import ReleaseTransformations._

val sonatypeReleaseAll = ReleaseStep(
action = Command.process("sonatypeReleaseAll", _))
val sonatypeReleaseAll = ReleaseStep(action = Command.process("sonatypeReleaseAll", _))
val dockerRelease = ReleaseStep(action = st => {
val extracted = Project.extract(st)
val extracted = Project.extract(st)
val projectRef: ProjectRef = extracted.get(thisProjectRef)
extracted.runAggregated(publish in Docker in projectRef, st)
st
@@ -173,8 +172,7 @@ lazy val quckoo = (project in file("."))
// Core ==================================================

lazy val core =
(crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file(
"core"))
(crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file("core"))
.enablePlugins(BuildInfoPlugin, AutomateHeaderPlugin)
.settings(
name := "core",
@@ -193,14 +191,13 @@ lazy val core =
.jvmSettings(Dependencies.coreJVM)
.dependsOn(util, testSupport % Test)

lazy val coreJS = core.js
lazy val coreJS = core.js
lazy val coreJVM = core.jvm

// API ==================================================

lazy val api =
(crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file(
"api"))
(crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file("api"))
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings)
.settings(scoverageSettings)
@@ -214,7 +211,7 @@ lazy val api =
)
.dependsOn(core, testSupport % Test)

lazy val apiJS = api.js
lazy val apiJS = api.js
lazy val apiJVM = api.jvm

// Client ==================================================
@@ -231,12 +228,11 @@ lazy val client = (crossProject(JSPlatform, JVMPlatform) in file("client"))
.jvmSettings(Dependencies.clientJVM)
.settings(
name := "client",
moduleName := "quckoo-client",
requiresDOM := true
moduleName := "quckoo-client"
)
.dependsOn(api, testSupport % Test)

lazy val clientJS = client.js
lazy val clientJS = client.js
lazy val clientJVM = client.jvm

// Console ==================================================
@@ -250,7 +246,6 @@ lazy val console = (project in file("console"))
.settings(
name := "console",
moduleName := "quckoo-console",
requiresDOM := true,
scalaJSUseMainModuleInitializer in Compile := true
)
.dependsOn(clientJS, testSupportJS % Test)
@@ -316,7 +311,7 @@ lazy val util = (crossProject(JSPlatform, JVMPlatform) in file("util"))
.settings(moduleName := "quckoo-util")
.dependsOn(testSupport % Test)

lazy val utilJS = util.js
lazy val utilJS = util.js
lazy val utilJVM = util.jvm

// Test Support Utilities ===================================
@@ -335,7 +330,7 @@ lazy val testSupport =
moduleName := "quckoo-test-support"
)

lazy val testSupportJS = testSupport.js
lazy val testSupportJS = testSupport.js
lazy val testSupportJVM = testSupport.jvm

// Examples ==================================================
@@ -32,17 +32,15 @@ import slogging.LazyLogging
* Created by alonsodomin on 02/04/2016.
*/
private[dom] class EventSourceSubscriber(topicName: String)
extends (Subscriber.Sync[HttpServerSentEvent] => Cancelable)
with LazyLogging {
extends (Subscriber.Sync[HttpServerSentEvent] => Cancelable) with LazyLogging {

val topicURL: String = topicURI(topicName)

logger.debug("Subscribing to topic '{}' using URL: {}", topicName, topicURL)

val source = new EventSource(topicURL)

override def apply(
subscriber: Subscriber.Sync[HttpServerSentEvent]): Cancelable = {
override def apply(subscriber: Subscriber.Sync[HttpServerSentEvent]): Cancelable = {
val cancelable = RefCountCancelable { () =>
subscriber.onComplete()
source.close
@@ -50,14 +50,13 @@ private[http] object HttpDOMBackend extends HttpBackend {
else 0
}

val domReq = new XMLHttpRequest()
val domReq = new XMLHttpRequest()
val promise = Promise[HttpResponse]()

domReq.onreadystatechange = { (e: DOMEvent) =>
if (domReq.readyState == 4) {
val entityData =
DataBuffer(
TypedArrayBuffer.wrap(domReq.response.asInstanceOf[ArrayBuffer]))
DataBuffer(TypedArrayBuffer.wrap(domReq.response.asInstanceOf[ArrayBuffer]))
val response =
HttpResponse(domReq.status, domReq.statusText, entityData)
promise.success(response)
@@ -25,6 +25,6 @@ import io.quckoo.client.core.DriverBackend
package object dom {

implicit val backend: DriverBackend[HttpProtocol] = HttpDOMBackend
val HttpDOMQuckooClient = QuckooClient[HttpProtocol]
val HttpDOMQuckooClient = QuckooClient[HttpProtocol]

}
@@ -20,12 +20,7 @@ import akka.NotUsed
import akka.actor.ActorSystem
import akka.http.scaladsl.client.RequestBuilding.Get
import akka.http.scaladsl.model.HttpHeader.ParsingResult
import akka.http.scaladsl.model.{
ContentTypes,
HttpEntity,
HttpHeader,
HttpMethods
}
import akka.http.scaladsl.model.{ContentTypes, HttpEntity, HttpHeader, HttpMethods}
import akka.http.scaladsl.model.{
HttpMethod => AkkaHttpMethod,
HttpRequest => AkkaHttpRequest,
@@ -54,8 +49,8 @@ import scala.concurrent.Future
/**
* Created by alonsodomin on 11/09/2016.
*/
private[http] final class HttpAkkaBackend(host: String, port: Int = 80)(
implicit val actorSystem: ActorSystem)
private[http] final class HttpAkkaBackend(host: String,
port: Int = 80)(implicit val actorSystem: ActorSystem)
extends HttpBackend {

implicit val materializer =
@@ -72,61 +67,60 @@ private[http] final class HttpAkkaBackend(host: String, port: Int = 80)(

val source = for {
response <- AkkaHttp().singleRequest(
Get(s"http://$host:$port" + topicURI(channel.topicTag.name)))
Get(s"http://$host:$port" + topicURI(channel.topicTag.name))
)
events <- Unmarshal(response).to[Source[ServerSentEvent, NotUsed]]
} yield events.runWith(publisherSink)

for {
publisher <- Observable.fromFuture(source)
event <- Observable.fromReactivePublisher(publisher)
event <- Observable.fromReactivePublisher(publisher)
} yield {
HttpServerSentEvent(DataBuffer.fromString(event.toString))
}
}

override def send: Kleisli[Future, HttpRequest, HttpResponse] = Kleisli {
req =>
def method: AkkaHttpMethod = req.method match {
case HttpMethod.Get => HttpMethods.GET
case HttpMethod.Put => HttpMethods.PUT
case HttpMethod.Post => HttpMethods.POST
case HttpMethod.Delete => HttpMethods.DELETE
}
override def send: Kleisli[Future, HttpRequest, HttpResponse] = Kleisli { req =>
def method: AkkaHttpMethod = req.method match {
case HttpMethod.Get => HttpMethods.GET
case HttpMethod.Put => HttpMethods.PUT
case HttpMethod.Post => HttpMethods.POST
case HttpMethod.Delete => HttpMethods.DELETE
}

val headers = {
req.headers
.filterKeys(_ != "Content-Type")
.map({
case (name, value) => HttpHeader.parse(name, value)
})
.flatMap {
case ParsingResult.Ok(header, _) => Seq(header)
case _ => Seq()
}
.to[immutable.Seq]
}
val headers = {
req.headers
.filterKeys(_ != "Content-Type")
.map({
case (name, value) => HttpHeader.parse(name, value)
})
.flatMap {
case ParsingResult.Ok(header, _) => Seq(header)
case _ => Seq()
}
.to[immutable.Seq]
}

def parseRawResponse(response: AkkaHttpResponse): Future[HttpResponse] = {
val entityData = response.entity.dataBytes.runFold(ByteString())(_ ++ _)
def parseRawResponse(response: AkkaHttpResponse): Future[HttpResponse] = {
val entityData = response.entity.dataBytes.runFold(ByteString())(_ ++ _)

import actorSystem.dispatcher
entityData.map(
buff =>
HttpResponse(response.status.intValue(),
response.status.value,
DataBuffer.fromString(buff.utf8String)))
}
import actorSystem.dispatcher
entityData.map(
buff =>
HttpResponse(
response.status.intValue(),
response.status.value,
DataBuffer.fromString(buff.utf8String)
)
)
}

val entity =
HttpEntity(ContentTypes.`application/json`, req.entity.asString())
Source
.single(
AkkaHttpRequest(method,
uri = req.url,
entity = entity,
headers = headers))
.via(connection)
.mapAsync(1)(parseRawResponse)
.runWith(Sink.head[HttpResponse])
val entity =
HttpEntity(ContentTypes.`application/json`, req.entity.asString())
Source
.single(AkkaHttpRequest(method, uri = req.url, entity = entity, headers = headers))
.via(connection)
.mapAsync(1)(parseRawResponse)
.runWith(Sink.head[HttpResponse])
}
}
@@ -25,9 +25,10 @@ import io.quckoo.client.http._
* Created by alonsodomin on 21/09/2016.
*/
object HttpAkkaQuckooClient {
def apply(host: String, port: Int = 80)(implicit
actorSystem: ActorSystem =
ActorSystem("HttpQuckooClient")) = {
def apply(host: String, port: Int = 80)(
implicit
actorSystem: ActorSystem = ActorSystem("HttpQuckooClient")
) = {
implicit val backend = new HttpAkkaBackend(host, port)
QuckooClient[HttpProtocol]
}

0 comments on commit 4ae4113

Please sign in to comment.
You can’t perform that action at this time.