Initial commit
This commit is contained in:
78
.gitignore
vendored
Normal file
78
.gitignore
vendored
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
### Scala template
|
||||||
|
*.class
|
||||||
|
*.log
|
||||||
|
### SBT template
|
||||||
|
# Simple Build Tool
|
||||||
|
# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control
|
||||||
|
|
||||||
|
dist/*
|
||||||
|
target/
|
||||||
|
lib_managed/
|
||||||
|
src_managed/
|
||||||
|
project/boot/
|
||||||
|
project/plugins/project/
|
||||||
|
.history
|
||||||
|
.cache
|
||||||
|
.lib/
|
||||||
4
.idea/encodings.xml
generated
Normal file
4
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||||
|
</project>
|
||||||
9
.idea/hydra.xml
generated
Normal file
9
.idea/hydra.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="HydraSettings">
|
||||||
|
<option name="hydraStorePath" value="$PROJECT_DIR$/.hydra/idea" />
|
||||||
|
<option name="noOfCores" value="2" />
|
||||||
|
<option name="projectRoot" value="$PROJECT_DIR$" />
|
||||||
|
<option name="sourcePartitioner" value="auto" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/classes" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.idea/modules.xml
generated
Normal file
9
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/scala-learn-1.iml" filepath="$PROJECT_DIR$/.idea/modules/scala-learn-1.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/scala-learn-1-build.iml" filepath="$PROJECT_DIR$/.idea/modules/scala-learn-1-build.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
139
.idea/modules/scala-learn-1-build.iml
generated
Normal file
139
.idea/modules/scala-learn-1-build.iml
generated
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.id="scala-learn-1-build" external.linked.project.path="$MODULE_DIR$/../../project" external.root.project.path="$MODULE_DIR$/../.." external.system.id="SBT" sbt.imports="_root_.sbt.Keys._, _root_.sbt.ScriptedPlugin.autoImport._, _root_.sbtprotoc.ProtocPlugin.autoImport._, _root_.sbtassembly.AssemblyPlugin.autoImport._, _root_.com.lightbend.sbt.javaagent.JavaAgent.autoImport._, _root_.sbt._, _root_.sbt.plugins.IvyPlugin, _root_.sbt.plugins.JvmPlugin, _root_.sbt.plugins.CorePlugin, _root_.sbt.ScriptedPlugin, _root_.sbt.plugins.SbtPlugin, _root_.sbt.plugins.JUnitXmlReportPlugin, _root_.sbt.plugins.Giter8TemplatePlugin, _root_.sbtprotoc.ProtocPlugin, _root_.sbtassembly.AssemblyPlugin, _root_.kamon.aspectj.sbt.SbtAspectJRunner, _root_.com.lightbend.sbt.javaagent.JavaAgent, _root_.com.lightbend.sbt.javaagent.JavaAgentPackaging, _root_.scala.xml.{TopScope=&gt;SUB:DOLLARscope}" sbt.resolvers="https://repo1.maven.org/maven2/|maven|public, file:/home/nnm/.sbt/preloaded/|maven|local-preloaded, /home/nnm/.ivy2/cache|ivy|Local cache" type="SBT_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<output url="file://$MODULE_DIR$/../../project/target/idea-classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/../../project/target/idea-test-classes" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$/../../project">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../project" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../project/project/target" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../project/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="sbt: sbt-and-plugins">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/com.github.os72/protoc-jar/jars/protoc-jar-3.5.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/com.google.protobuf/protobuf-java/bundles/protobuf-java-3.5.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/com.thesamet.scalapb/compilerplugin_2.12/jars/compilerplugin_2.12-0.7.4.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/com.thesamet.scalapb/protoc-bridge_2.12/jars/protoc-bridge_2.12-0.7.3.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/javax.annotation/jsr250-api/jars/jsr250-api-1.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/javax.enterprise/cdi-api/jars/cdi-api-1.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/javax.inject/javax.inject/jars/javax.inject-1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.apache.ant/ant-launcher/jars/ant-launcher-1.9.9.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.apache.ant/ant/jars/ant-1.9.9.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.apache.commons/commons-lang3/jars/commons-lang3-3.4.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.apache.maven/maven-artifact/jars/maven-artifact-3.3.9.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.apache.maven/maven-model/jars/maven-model-3.3.9.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.apache.maven/maven-plugin-api/jars/maven-plugin-api-3.3.9.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.aspectj/aspectjtools/jars/aspectjtools-1.8.13.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.codehaus.plexus/plexus-classworlds/bundles/plexus-classworlds-2.5.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.codehaus.plexus/plexus-component-annotations/jars/plexus-component-annotations-1.5.5.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.codehaus.plexus/plexus-utils/jars/plexus-utils-3.0.22.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.eclipse.sisu/org.eclipse.sisu.inject/eclipse-plugins/org.eclipse.sisu.inject-0.3.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.eclipse.sisu/org.eclipse.sisu.plexus/eclipse-plugins/org.eclipse.sisu.plexus-0.3.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.ow2.asm/asm-commons/jars/asm-commons-6.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.ow2.asm/asm-tree/jars/asm-tree-6.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.ow2.asm/asm/jars/asm-6.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.pantsbuild/jarjar/jars/jarjar-1.6.5.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/org.scalactic/scalactic_2.12/bundles/scalactic_2.12-3.0.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/scala_2.12/sbt_1.0/com.eed3si9n/sbt-assembly/jars/sbt-assembly-0.14.7.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/scala_2.12/sbt_1.0/com.lightbend.sbt/sbt-javaagent/jars/sbt-javaagent-0.1.4.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/scala_2.12/sbt_1.0/com.thesamet/sbt-protoc/jars/sbt-protoc-0.99.18.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.ivy2/cache/scala_2.12/sbt_1.0/io.kamon/sbt-aspectj-runner/jars/sbt-aspectj-runner-1.1.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/lib/jline.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/lib/scala-compiler.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/lib/scala-library.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/lib/scala-reflect.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/lib/scala-xml_2.12.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/actions_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/apple-file-events-1.3.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/caffeine-2.5.6.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/collections_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/command_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/compiler-interface-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/completion_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/config-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/core-macros_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/disruptor-3.3.6.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/fastparse-utils_2.12-0.4.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/fastparse_2.12-0.4.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/gigahorse-core_2.12-0.3.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/gigahorse-okhttp_2.12-0.3.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/io_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/ipcsocket-1.0.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/ivy-2.3.0-sbt-b18f59ea3bc914a297bb6f1a4f7fb0ace399e310.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/jawn-parser_2.12-0.10.4.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/jline-2.14.6.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/jna-4.5.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/jna-platform-4.5.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/jsch-0.1.54.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/launcher-interface-1.0.4.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/lenses_2.12-0.4.12.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/librarymanagement-core_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/librarymanagement-ivy_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/log4j-api-2.8.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/log4j-core-2.8.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/log4j-slf4j-impl-2.8.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/logic_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/main-settings_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/main_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/okhttp-3.7.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/okhttp-urlconnection-3.7.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/okio-1.12.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/protobuf-java-3.3.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/protocol_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/reactive-streams-1.0.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/run_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/sbinary_2.12-0.4.4.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/sbt-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/scala-parser-combinators_2.12-1.0.5.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/scala-reflect-2.12.6.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/scala-xml_2.12-1.0.6.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/scalacache-caffeine_2.12-0.20.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/scalacache-core_2.12-0.20.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/scalapb-runtime_2.12-0.6.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/scripted-plugin_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/scripted-sbt-redux_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/shaded-scalajson_2.12-1.0.0-M4.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/sjson-new-core_2.12-0.8.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/sjson-new-murmurhash_2.12-0.8.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/sjson-new-scalajson_2.12-0.8.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/slf4j-api-1.7.25.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/sourcecode_2.12-0.1.3.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/ssl-config-core_2.12-0.2.2.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/task-system_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/tasks_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/template-resolver-0.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/test-agent-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/test-interface-1.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/testing_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/util-cache_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/util-control_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/util-interface-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/util-logging_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/util-position_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/util-relation_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/util-scripted_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/util-tracking_2.12-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc-apiinfo_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc-classfile_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc-classpath_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc-compile-core_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc-compile_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc-core_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc-ivy-integration_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc-persist_2.12-1.2.1.jar!/" />
|
||||||
|
<root url="jar://$USER_HOME$/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.2.1/zinc_2.12-1.2.1.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
</component>
|
||||||
|
<component name="SbtModule">
|
||||||
|
<option name="buildForURI" value="file:$MODULE_DIR$/../../" />
|
||||||
|
<option name="imports" value="_root_.sbt.Keys._, _root_.sbt.ScriptedPlugin.autoImport._, _root_.sbtprotoc.ProtocPlugin.autoImport._, _root_.sbtassembly.AssemblyPlugin.autoImport._, _root_.com.lightbend.sbt.javaagent.JavaAgent.autoImport._, _root_.sbt._, _root_.sbt.plugins.IvyPlugin, _root_.sbt.plugins.JvmPlugin, _root_.sbt.plugins.CorePlugin, _root_.sbt.ScriptedPlugin, _root_.sbt.plugins.SbtPlugin, _root_.sbt.plugins.JUnitXmlReportPlugin, _root_.sbt.plugins.Giter8TemplatePlugin, _root_.sbtprotoc.ProtocPlugin, _root_.sbtassembly.AssemblyPlugin, _root_.kamon.aspectj.sbt.SbtAspectJRunner, _root_.com.lightbend.sbt.javaagent.JavaAgent, _root_.com.lightbend.sbt.javaagent.JavaAgentPackaging, _root_.scala.xml.{TopScope=>SUB:DOLLARscope}" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
68
.idea/modules/scala-learn-1.iml
generated
Normal file
68
.idea/modules/scala-learn-1.iml
generated
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.id="scala-learn-1 [file:/home/nnm/development/scala-learn-1/]" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="SBT" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
|
<output url="file://$MODULE_DIR$/../../target/scala-2.12/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/../../target/scala-2.12/test-classes" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$/../..">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../src/main/scala" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../src/test/scala" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../target/scala-2.12/src_managed/main" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../target/scala-2.12/src_managed/test" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../src/main/resources" type="java-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../target" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../target/protobuf_external" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../target/streams" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../target/test-reports" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="sbt: org.scala-lang:scala-library:2.12.6:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.mongodb.scala:mongo-scala-driver_2.12:2.6.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.mongodb.scala:mongo-scala-bson_2.12:2.6.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.mongodb:mongodb-driver-core:3.10.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.mongodb:mongodb-driver-async:3.10.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.mongodb:bson:3.10.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe.akka:akka-stream_2.12:2.5.22:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe.akka:akka-protobuf_2.12:2.5.22:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe.akka:akka-actor_2.12:2.5.22:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.thesamet.scalapb:scalapb-runtime_2.12:0.7.4:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.thesamet.scalapb:lenses_2.12:0.7.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.lihaoyi:sourcecode_2.12:0.1.4:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.lihaoyi:fastparse_2.12:1.0.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.lihaoyi:fastparse-utils_2.12:1.0.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.google.protobuf:protobuf-java:3.5.1:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.slf4j:slf4j-api:1.7.25:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.hdrhistogram:HdrHistogram:2.1.9:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.aspectj:aspectjweaver:1.9.1:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.agrona:agrona:0.9.17:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.netty:netty:3.10.6.Final:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.kamon:kamon-scala-future_2.12:1.0.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.kamon:kamon-logback_2.12:1.0.3:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.kamon:kamon-executors_2.12:1.0.1:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.kamon:kamon-core_2.12:1.1.3:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.kamon:kamon-akka-remote-2.5_2.12:1.1.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.kamon:kamon-akka-http-2.5_2.12:1.1.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.kamon:kamon-akka-2.5_2.12:1.1.2:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.aeron:aeron-driver:1.9.1:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: io.aeron:aeron-client:1.9.1:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe.akka:akka-remote_2.12:2.5.13:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe.akka:akka-parsing_2.12:10.0.11:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe.akka:akka-http_2.12:10.0.11:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe.akka:akka-http-core_2.12:10.0.11:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe.akka:akka-cluster_2.12:2.5.13:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.lihaoyi:fansi_2.12:0.2.4:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: ch.qos.logback:logback-core:1.2.3:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: ch.qos.logback:logback-classic:1.2.3:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.scala-lang.modules:scala-parser-combinators_2.12:1.1.1:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.scala-lang.modules:scala-java8-compat_2.12:0.8.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.reactivestreams:reactive-streams:1.0.2:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: org.scala-lang:scala-reflect:2.12.6:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe:config:1.3.3:jar" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="sbt: org.scala-lang.modules:scala-xml_2.12:1.0.6:jar" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="sbt: org.scalactic:scalactic_2.12:3.0.5:jar" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="sbt: org.scalamock:scalamock_2.12:4.1.0:jar" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="sbt: org.scalatest:scalatest_2.12:3.0.5:jar" level="project" />
|
||||||
|
<orderEntry type="library" name="sbt: com.typesafe:ssl-config-core_2.12:0.3.7:jar" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
18
.idea/sbt.xml
generated
Normal file
18
.idea/sbt.xml
generated
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ScalaSbtSettings">
|
||||||
|
<option name="customVMPath" />
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<SbtProjectSettings>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/project" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="sbtVersion" value="1.2.1" />
|
||||||
|
</SbtProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/scala_compiler.xml
generated
Normal file
6
.idea/scala_compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ScalaCompilerConfiguration">
|
||||||
|
<profile name="sbt 1" modules="scala-learn-1_7716,scala-learn-1" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
2
application.conf
Normal file
2
application.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
field1.field2 = 11
|
||||||
|
field1.field3 = 15
|
||||||
28
build.sbt
Normal file
28
build.sbt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import scala.sys.process.Process
|
||||||
|
|
||||||
|
scalaVersion := "2.12.6"
|
||||||
|
|
||||||
|
mainClass in Compile := Some("eu.xeppaka.scalalearn.Main")
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"com.typesafe.akka" %% "akka-actor" % "2.5.22",
|
||||||
|
"com.typesafe.akka" %% "akka-stream" % "2.5.22",
|
||||||
|
"com.typesafe" % "config" % "1.3.3",
|
||||||
|
"org.mongodb.scala" %% "mongo-scala-driver" % "2.6.0",
|
||||||
|
"io.kamon" %% "kamon-core" % "1.1.3",
|
||||||
|
"io.kamon" %% "kamon-scala-future" % "1.0.0",
|
||||||
|
"io.kamon" %% "kamon-akka-2.5" % "1.1.2",
|
||||||
|
"io.kamon" %% "kamon-akka-http-2.5" % "1.1.0",
|
||||||
|
"io.kamon" %% "kamon-akka-remote-2.5" % "1.1.0",
|
||||||
|
"io.kamon" %% "kamon-logback" % "1.0.3",
|
||||||
|
"org.aspectj" % "aspectjweaver" % "1.9.1",
|
||||||
|
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf",
|
||||||
|
"org.scalatest" %% "scalatest" % "3.0.5" % Test,
|
||||||
|
"org.scalamock" %% "scalamock" % "4.1.0" % Test
|
||||||
|
)
|
||||||
|
|
||||||
|
fork := true
|
||||||
|
runMain / javaOptions += "-J-Xmx512M"
|
||||||
|
PB.runProtoc in Compile := (args => Process("/run/current-system/sw/bin/protoc", args)!)
|
||||||
|
PB.targets in Compile := Seq(
|
||||||
|
scalapb.gen() -> (sourceManaged in Compile).value
|
||||||
|
)
|
||||||
1
project/build.properties
Normal file
1
project/build.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
sbt.version=1.2.1
|
||||||
3
project/plugins.sbt
Normal file
3
project/plugins.sbt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.7")
|
||||||
|
addSbtPlugin("io.kamon" % "sbt-aspectj-runner" % "1.1.1")
|
||||||
|
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.4")
|
||||||
3
project/protoc.sbt
Normal file
3
project/protoc.sbt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.18")
|
||||||
|
|
||||||
|
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.7.4"
|
||||||
16
src/main/protobuf/Messages.proto
Normal file
16
src/main/protobuf/Messages.proto
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
syntax = "proto2";
|
||||||
|
package eu.xeppaka.scalalearn;
|
||||||
|
|
||||||
|
import "scalapb/scalapb.proto";
|
||||||
|
|
||||||
|
option (scalapb.options) = {
|
||||||
|
flat_package: true
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Status {
|
||||||
|
OPEN = 0;
|
||||||
|
CLOSED = 1;
|
||||||
|
BLOCKED_IN = 2;
|
||||||
|
BLOCKED_OUT = 3;
|
||||||
|
BLOCKED_ALL = 4;
|
||||||
|
}
|
||||||
5
src/main/resources/application.conf
Normal file
5
src/main/resources/application.conf
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
var1 = {
|
||||||
|
val1 = 1
|
||||||
|
val2 = 2
|
||||||
|
}
|
||||||
|
include "test.conf"
|
||||||
47
src/main/scala/eu/xeppaka/scalalearn/Actor1.scala
Normal file
47
src/main/scala/eu/xeppaka/scalalearn/Actor1.scala
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.{Actor, ActorLogging, ActorRef, Props}
|
||||||
|
import akka.stream.{ActorMaterializer, Materializer}
|
||||||
|
import akka.stream.scaladsl.{Keep, Sink, Source}
|
||||||
|
import akka.util.Timeout
|
||||||
|
import eu.xeppaka.scalalearn.Actor1.{FinishFailure, FinishSuccess, Print, Start}
|
||||||
|
import eu.xeppaka.scalalearn.Actor2._
|
||||||
|
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import scala.util.{Failure, Success}
|
||||||
|
|
||||||
|
object Actor1 {
|
||||||
|
case object Start
|
||||||
|
case object FinishSuccess
|
||||||
|
case object FinishFailure
|
||||||
|
case object Print
|
||||||
|
|
||||||
|
def props(actor2: ActorRef): Props = Props(new Actor1(actor2))
|
||||||
|
}
|
||||||
|
|
||||||
|
class Actor1(actor2: ActorRef) extends Actor with ActorLogging {
|
||||||
|
import context.dispatcher
|
||||||
|
|
||||||
|
implicit val timeout: Timeout = 2.seconds
|
||||||
|
implicit val materializer: Materializer = ActorMaterializer()
|
||||||
|
|
||||||
|
override def receive: Receive = {
|
||||||
|
case Start =>
|
||||||
|
Source
|
||||||
|
.repeat(Request)
|
||||||
|
.take(100)
|
||||||
|
.ask[Response.type](actor2)
|
||||||
|
.toMat(Sink.foreach(response => log.info(response.toString)))(Keep.right)
|
||||||
|
.run()
|
||||||
|
.onComplete {
|
||||||
|
case Success(_) => self ! FinishSuccess
|
||||||
|
case Failure(_) => self ! FinishFailure
|
||||||
|
}
|
||||||
|
case FinishSuccess =>
|
||||||
|
log.info("actor1 finish success")
|
||||||
|
case FinishFailure =>
|
||||||
|
log.info("actor1 finish failure")
|
||||||
|
case Print =>
|
||||||
|
log.info("print done")
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/main/scala/eu/xeppaka/scalalearn/Actor2.scala
Normal file
26
src/main/scala/eu/xeppaka/scalalearn/Actor2.scala
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.{Actor, ActorLogging, ActorRef, Props}
|
||||||
|
import eu.xeppaka.scalalearn.Actor2.{Request, Response, SendResponse}
|
||||||
|
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
object Actor2 {
|
||||||
|
case object Request
|
||||||
|
case object Response
|
||||||
|
private case class SendResponse(destination: ActorRef)
|
||||||
|
|
||||||
|
def props(): Props = Props(new Actor2())
|
||||||
|
}
|
||||||
|
|
||||||
|
class Actor2 extends Actor with ActorLogging {
|
||||||
|
import context.dispatcher
|
||||||
|
|
||||||
|
override def receive: Receive = {
|
||||||
|
case Request =>
|
||||||
|
log.info("actor2 request")
|
||||||
|
context.system.scheduler.scheduleOnce(10.millis, self, SendResponse(sender()))
|
||||||
|
case SendResponse(destination) =>
|
||||||
|
destination ! Response
|
||||||
|
}
|
||||||
|
}
|
||||||
59
src/main/scala/eu/xeppaka/scalalearn/ActorTest1.scala
Normal file
59
src/main/scala/eu/xeppaka/scalalearn/ActorTest1.scala
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.{Actor, OneForOneStrategy, PoisonPill, SupervisorStrategy, Timers}
|
||||||
|
import ActorTest1._
|
||||||
|
|
||||||
|
import scala.concurrent.ExecutionContextExecutor
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import akka.actor.SupervisorStrategy._
|
||||||
|
|
||||||
|
object ActorTest1 {
|
||||||
|
case object Create
|
||||||
|
case object Delete
|
||||||
|
case object Print
|
||||||
|
}
|
||||||
|
|
||||||
|
class ActorTest1 extends Actor {
|
||||||
|
|
||||||
|
override val supervisorStrategy: SupervisorStrategy = OneForOneStrategy() {
|
||||||
|
case _ => Restart
|
||||||
|
}
|
||||||
|
|
||||||
|
case class State(
|
||||||
|
exist: Boolean = false
|
||||||
|
)
|
||||||
|
|
||||||
|
private var state = State()
|
||||||
|
|
||||||
|
override def preStart(): Unit = {
|
||||||
|
super.preStart()
|
||||||
|
|
||||||
|
implicit val executionContext: ExecutionContextExecutor = context.dispatcher
|
||||||
|
//context.system.scheduler.scheduleOnce(2.seconds, self, PoisonPill)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def postStop(): Unit = {
|
||||||
|
super.postStop()
|
||||||
|
println(s"actor ${self.path.name} stopped.")
|
||||||
|
}
|
||||||
|
|
||||||
|
val exist: Receive = {
|
||||||
|
case Create =>
|
||||||
|
case Delete => state = state.copy(exist = false)
|
||||||
|
case Print => println(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
val notExist: Receive = {
|
||||||
|
case Create => state = state.copy(exist = true)
|
||||||
|
case Delete =>
|
||||||
|
case Print =>
|
||||||
|
println(state)
|
||||||
|
//throw new Exception("blah")
|
||||||
|
//throw new Throwable("blah")
|
||||||
|
}
|
||||||
|
|
||||||
|
override val receive: Receive = {
|
||||||
|
case message: Any if state.exist => exist(message)
|
||||||
|
case message: Any if !state.exist => notExist(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/main/scala/eu/xeppaka/scalalearn/CacheUser.scala
Normal file
33
src/main/scala/eu/xeppaka/scalalearn/CacheUser.scala
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
import akka.actor.{Actor, ActorRef, Props}
|
||||||
|
import eu.xeppaka.scalalearn.CacheUser.{CacheRandomCard, CacheRandomCard2, TestMsg, TestMsgSuccess}
|
||||||
|
import eu.xeppaka.scalalearn.CardCacheActor.{CacheCard, CacheSuccess}
|
||||||
|
|
||||||
|
object CacheUser {
|
||||||
|
case object CacheRandomCard
|
||||||
|
case object CacheRandomCard2
|
||||||
|
case object TestMsg
|
||||||
|
|
||||||
|
case class TestMsgSuccess(msg: Option[String])
|
||||||
|
case object TestMsgFailure
|
||||||
|
|
||||||
|
def props(cardCacheApi: CardCacheApi, cache: ActorRef): Props = Props(classOf[CacheUser], cardCacheApi, cache)
|
||||||
|
}
|
||||||
|
|
||||||
|
class CacheUser(cardCacheApi: CardCacheApi, cache: ActorRef) extends Actor {
|
||||||
|
override def receive: Receive = {
|
||||||
|
case CacheRandomCard =>
|
||||||
|
println(s"name: ${self.path.name}")
|
||||||
|
cardCacheApi.cacheCard(UUID.randomUUID().toString)
|
||||||
|
case CacheRandomCard2 =>
|
||||||
|
cache ! CacheCard(UUID.randomUUID().toString)
|
||||||
|
case TestMsg =>
|
||||||
|
println(s"name: ${self.path.toStringWithoutAddress}")
|
||||||
|
sender() ! TestMsgSuccess(Some("data"))
|
||||||
|
case CacheSuccess =>
|
||||||
|
println("cache success!")
|
||||||
|
}
|
||||||
|
}
|
||||||
19
src/main/scala/eu/xeppaka/scalalearn/CardCacheActor.scala
Normal file
19
src/main/scala/eu/xeppaka/scalalearn/CardCacheActor.scala
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.Actor
|
||||||
|
import eu.xeppaka.scalalearn.CardCacheActor.{CacheCard, CacheSuccess}
|
||||||
|
|
||||||
|
object CardCacheActor {
|
||||||
|
case class CacheCard(idCard: String)
|
||||||
|
case object CacheSuccess
|
||||||
|
}
|
||||||
|
|
||||||
|
class CardCacheActor extends Actor {
|
||||||
|
override def receive: Receive = {
|
||||||
|
case CacheCard(idCard) =>
|
||||||
|
println("cache card")
|
||||||
|
sender() ! CacheSuccess
|
||||||
|
case _ =>
|
||||||
|
println("error!")
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/main/scala/eu/xeppaka/scalalearn/CardCacheApi.scala
Normal file
8
src/main/scala/eu/xeppaka/scalalearn/CardCacheApi.scala
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.ActorRef
|
||||||
|
import eu.xeppaka.scalalearn.CardCacheActor.CacheCard
|
||||||
|
|
||||||
|
class CardCacheApi(val cacheActor: ActorRef) {
|
||||||
|
def cacheCard(idCard: String): Unit = cacheActor ! CacheCard(idCard)
|
||||||
|
}
|
||||||
27
src/main/scala/eu/xeppaka/scalalearn/Class23.scala
Normal file
27
src/main/scala/eu/xeppaka/scalalearn/Class23.scala
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
case class Class23(
|
||||||
|
field1: String,
|
||||||
|
field2: String,
|
||||||
|
field3: String,
|
||||||
|
field4: String,
|
||||||
|
field5: String,
|
||||||
|
field6: String,
|
||||||
|
field7: String,
|
||||||
|
field8: String,
|
||||||
|
field9: String,
|
||||||
|
field10: String,
|
||||||
|
field11: String,
|
||||||
|
field12: String,
|
||||||
|
field13: String,
|
||||||
|
field14: String,
|
||||||
|
field15: String,
|
||||||
|
field16: String,
|
||||||
|
field17: String,
|
||||||
|
field18: String,
|
||||||
|
field19: String,
|
||||||
|
field20: String,
|
||||||
|
field21: String,
|
||||||
|
field22: String,
|
||||||
|
field23: String
|
||||||
|
)
|
||||||
80
src/main/scala/eu/xeppaka/scalalearn/Main.scala
Normal file
80
src/main/scala/eu/xeppaka/scalalearn/Main.scala
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.ActorSystem
|
||||||
|
import akka.stream.{ActorMaterializer, OverflowStrategy}
|
||||||
|
import akka.stream.scaladsl.{Keep, Sink, Source}
|
||||||
|
import org.mongodb.scala.bson.BsonValue
|
||||||
|
import org.mongodb.scala.bson.collection.immutable.Document
|
||||||
|
import org.mongodb.scala.{MongoClient, MongoClientSettings, Observer, Subscription}
|
||||||
|
import org.mongodb.scala.model.Filters.{and, equal, gt, gte}
|
||||||
|
|
||||||
|
import scala.collection.mutable.ListBuffer
|
||||||
|
import scala.concurrent.duration.Duration
|
||||||
|
import scala.concurrent.{Await, Future, Promise}
|
||||||
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
|
import scala.util.{Failure, Success}
|
||||||
|
|
||||||
|
object Main {
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
implicit val actorSystem: ActorSystem = ActorSystem()
|
||||||
|
implicit val materializer: ActorMaterializer = ActorMaterializer()
|
||||||
|
|
||||||
|
val mongoClient = MongoClient("mongodb://begencardcore:Heslo_1234@10.18.255.53:27017,10.18.255.163:27017,10.18.255.118:27017/begencardcore?replicaSet=cluster-lcs-dvp-mw")
|
||||||
|
val db = mongoClient.getDatabase("begencardcore")
|
||||||
|
val coll = db.getCollection("snapshot")
|
||||||
|
|
||||||
|
val complete = Promise[Unit]()
|
||||||
|
val batchSize = 1000
|
||||||
|
var docs = ListBuffer[Document]()
|
||||||
|
|
||||||
|
val onNextDoc = (doc: Document) => {
|
||||||
|
coll
|
||||||
|
.find[Document](equal("idAccount", doc.get("idAccount").get))
|
||||||
|
.toFuture()
|
||||||
|
.map(_.headOption)
|
||||||
|
.andThen {
|
||||||
|
case Success(value) => println(value)
|
||||||
|
case Failure(exception) => println(exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val queue = Source
|
||||||
|
.queue[Document](1000, OverflowStrategy.backpressure)
|
||||||
|
.mapAsync(10)(onNextDoc)
|
||||||
|
.toMat(Sink.ignore)(Keep.left)
|
||||||
|
.run()
|
||||||
|
|
||||||
|
coll.find().subscribe(new Observer[Document] {
|
||||||
|
var processed: Long = 0
|
||||||
|
var subscription: Option[Subscription] = None
|
||||||
|
var processingFuture: Future[Unit] = Future.unit
|
||||||
|
|
||||||
|
override def onSubscribe(subscription: Subscription): Unit = {
|
||||||
|
this.subscription = Some(subscription)
|
||||||
|
subscription.request(batchSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def onNext(result: Document): Unit = {
|
||||||
|
queue
|
||||||
|
.offer(result)
|
||||||
|
.onComplete {
|
||||||
|
case Success(offerResult) => println(offerResult)
|
||||||
|
case Failure(exception) => println("offer failed")
|
||||||
|
}
|
||||||
|
processed = processed + 1
|
||||||
|
|
||||||
|
if (processed == batchSize) {
|
||||||
|
processed = 0
|
||||||
|
subscription.get.request(batchSize)
|
||||||
|
|
||||||
|
println(s"request next $batchSize...")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override def onError(e: Throwable): Unit = ()
|
||||||
|
override def onComplete(): Unit = complete.success(())
|
||||||
|
})
|
||||||
|
|
||||||
|
Await.ready(complete.future, Duration.Inf)
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/main/scala/eu/xeppaka/scalalearn/Main1.scala
Normal file
41
src/main/scala/eu/xeppaka/scalalearn/Main1.scala
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
|
import akka.actor.ActorSystem
|
||||||
|
import akka.stream.ActorMaterializer
|
||||||
|
import akka.stream.scaladsl.{Flow, Sink, Source}
|
||||||
|
|
||||||
|
import scala.concurrent.Await
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import scala.io.StdIn
|
||||||
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
|
object Main1 {
|
||||||
|
val mapsCount = 10000
|
||||||
|
|
||||||
|
def mapKey(idCard: String) = s"map-${math.abs(idCard.hashCode) % mapsCount}"
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
implicit val actorSystem: ActorSystem = ActorSystem()
|
||||||
|
implicit val materializer: ActorMaterializer = ActorMaterializer()
|
||||||
|
|
||||||
|
val resultMap = new ConcurrentHashMap[String, Int]()
|
||||||
|
val l = 1 to 200000
|
||||||
|
|
||||||
|
Source
|
||||||
|
.fromIterator(() => l.iterator)
|
||||||
|
.map(i => f"$i%032d")
|
||||||
|
.groupBy(mapsCount, idCard => mapKey(idCard))
|
||||||
|
.groupedWithin(100, 2.seconds)
|
||||||
|
.mergeSubstreams
|
||||||
|
.to(Sink.foreach(elems => elems.foreach(elem => resultMap.compute(mapKey(elem), (_, num) => num + 1))))
|
||||||
|
.run()
|
||||||
|
|
||||||
|
StdIn.readLine()
|
||||||
|
|
||||||
|
resultMap.entrySet().asScala.foreach(pair => if (pair.getValue >= 25) println(pair))
|
||||||
|
|
||||||
|
Await.ready(actorSystem.terminate(), 3.seconds)
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/main/scala/eu/xeppaka/scalalearn/Main10.scala
Normal file
14
src/main/scala/eu/xeppaka/scalalearn/Main10.scala
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import java.time.{Instant, LocalDateTime, ZoneId}
|
||||||
|
import java.time.temporal.{ChronoField, IsoFields}
|
||||||
|
|
||||||
|
object Main10 {
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val inst = Instant.parse("2011-02-11T12:00:00.00Z")
|
||||||
|
val ldt = LocalDateTime.ofInstant(inst, ZoneId.of("UTC"))
|
||||||
|
println(ldt.getDayOfWeek)
|
||||||
|
println(ldt.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR))
|
||||||
|
println(ldt.getMonthValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
44
src/main/scala/eu/xeppaka/scalalearn/Main11.scala
Normal file
44
src/main/scala/eu/xeppaka/scalalearn/Main11.scala
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.ActorSystem
|
||||||
|
import akka.stream.{ActorMaterializer, OverflowStrategy}
|
||||||
|
import akka.stream.scaladsl.{Sink, Source, Tcp}
|
||||||
|
import akka.util.ByteString
|
||||||
|
|
||||||
|
import scala.concurrent.Await
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import scala.io.StdIn
|
||||||
|
|
||||||
|
object Main11 {
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val actorSystem = ActorSystem()
|
||||||
|
val materializer = ActorMaterializer()(actorSystem)
|
||||||
|
|
||||||
|
val queue = Source
|
||||||
|
.queue[Int](0, OverflowStrategy.dropHead)
|
||||||
|
.map(i => {
|
||||||
|
println(s"before buffer elem: $i")
|
||||||
|
i
|
||||||
|
})
|
||||||
|
.map(i => {
|
||||||
|
println(s"after buffer elem: $i")
|
||||||
|
i
|
||||||
|
})
|
||||||
|
.map(i => ByteString.fromString(s"$i"))
|
||||||
|
.via(Tcp()(actorSystem).outgoingConnection("10.18.255.30", 9093))
|
||||||
|
.to(Sink.foreach(println))
|
||||||
|
.run()(materializer)
|
||||||
|
|
||||||
|
try {
|
||||||
|
println(Await.result(queue.offer(1), 2.seconds))
|
||||||
|
println(Await.result(queue.offer(2), 2.seconds))
|
||||||
|
println(Await.result(queue.offer(3), 2.seconds))
|
||||||
|
|
||||||
|
println("before readline")
|
||||||
|
|
||||||
|
StdIn.readLine()
|
||||||
|
} finally {
|
||||||
|
actorSystem.terminate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/main/scala/eu/xeppaka/scalalearn/Main12.scala
Normal file
28
src/main/scala/eu/xeppaka/scalalearn/Main12.scala
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.ActorSystem
|
||||||
|
import akka.stream.ActorMaterializer
|
||||||
|
import eu.xeppaka.scalalearn.Actor1.{Print, Start}
|
||||||
|
|
||||||
|
import scala.io.StdIn
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
object Main12 {
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val actorSystem = ActorSystem()
|
||||||
|
//val materializer = ActorMaterializer()(actorSystem)
|
||||||
|
|
||||||
|
try {
|
||||||
|
val actor2 = actorSystem.actorOf(Actor2.props())
|
||||||
|
val actor1 = actorSystem.actorOf(Actor1.props(actor2))
|
||||||
|
|
||||||
|
actorSystem.scheduler.schedule(1.second, 10.millis, actor1, Print)(actorSystem.dispatcher)
|
||||||
|
|
||||||
|
actor1 ! Start
|
||||||
|
|
||||||
|
StdIn.readLine()
|
||||||
|
} finally {
|
||||||
|
actorSystem.terminate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/main/scala/eu/xeppaka/scalalearn/Main13.scala
Normal file
28
src/main/scala/eu/xeppaka/scalalearn/Main13.scala
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import org.mongodb.scala.bson.codecs.Macros._
|
||||||
|
import org.mongodb.scala.bson.codecs.DEFAULT_CODEC_REGISTRY
|
||||||
|
import org.bson.codecs.configuration.CodecRegistries.{fromCodecs, fromProviders, fromRegistries}
|
||||||
|
import org.mongodb.scala.MongoClient
|
||||||
|
|
||||||
|
import scala.concurrent.Await
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
object Main13 {
|
||||||
|
case class SomeData(field1: String, field2: Option[String])
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val codecRegistry = fromRegistries(fromProviders(classOf[SomeData]), DEFAULT_CODEC_REGISTRY)
|
||||||
|
val mongo = MongoClient()
|
||||||
|
val db = mongo.getDatabase("db-0003").withCodecRegistry(codecRegistry)
|
||||||
|
val coll = db.getCollection[SomeData]("coll0001")
|
||||||
|
|
||||||
|
Await.ready(coll.insertOne(SomeData("field1", Some("field2"))).toFuture(), 1.second)
|
||||||
|
Await.ready(coll.insertOne(SomeData("field1", None)).toFuture(), 1.second)
|
||||||
|
|
||||||
|
val res = Await.result(coll.find().toFuture(), 2.seconds)
|
||||||
|
res.foreach(println)
|
||||||
|
|
||||||
|
mongo.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/main/scala/eu/xeppaka/scalalearn/Main2.scala
Normal file
35
src/main/scala/eu/xeppaka/scalalearn/Main2.scala
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.{ActorSystem, Props}
|
||||||
|
import akka.pattern.ask
|
||||||
|
import akka.stream.ActorMaterializer
|
||||||
|
import akka.util.Timeout
|
||||||
|
import eu.xeppaka.scalalearn.CacheUser.{TestMsg, TestMsgSuccess}
|
||||||
|
|
||||||
|
import scala.concurrent.{ExecutionContext, Future}
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import scala.util.Success
|
||||||
|
|
||||||
|
object Main2 {
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
implicit val actorSystem: ActorSystem = ActorSystem()
|
||||||
|
implicit val materializer: ActorMaterializer = ActorMaterializer()
|
||||||
|
implicit val timeout: Timeout = 1.second
|
||||||
|
implicit val ec: ExecutionContext = actorSystem.dispatcher
|
||||||
|
|
||||||
|
val cache = actorSystem.actorOf(Props(classOf[CardCacheActor]))
|
||||||
|
val cacheApi = new CardCacheApi(cache)
|
||||||
|
val cacheUser = actorSystem.actorOf(CacheUser.props(cacheApi, cache))
|
||||||
|
|
||||||
|
(cacheUser ? TestMsg)
|
||||||
|
.flatMap { vvv =>
|
||||||
|
println(vvv)
|
||||||
|
vvv match {
|
||||||
|
case TestMsgSuccess(Some(msg)) =>
|
||||||
|
println(msg)
|
||||||
|
Future.successful("success")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onComplete(vvv => println(vvv))
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/main/scala/eu/xeppaka/scalalearn/Main3.scala
Normal file
29
src/main/scala/eu/xeppaka/scalalearn/Main3.scala
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
|
import scala.concurrent.{Await, Future}
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
object Main3 {
|
||||||
|
def checkValue(value: String): Future[Option[Boolean]] = {
|
||||||
|
Future {
|
||||||
|
if (value == "true") Some(true) else Some(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val f = checkValue("test")
|
||||||
|
.map(b => b.map(!_))
|
||||||
|
.map(_.map(b =>
|
||||||
|
if (!b) {
|
||||||
|
b
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException()
|
||||||
|
}
|
||||||
|
).getOrElse(throw new IllegalStateException())
|
||||||
|
)
|
||||||
|
|
||||||
|
Await.ready(f, 1.second)
|
||||||
|
println(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/main/scala/eu/xeppaka/scalalearn/Main4.scala
Normal file
24
src/main/scala/eu/xeppaka/scalalearn/Main4.scala
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import org.mongodb.scala.MongoClient
|
||||||
|
import org.mongodb.scala.bson.collection.immutable.Document
|
||||||
|
|
||||||
|
import scala.concurrent.Await
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
object Main4 {
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val mongoClient = MongoClient("mongodb://localhost:27017/?maxPoolSize=2")
|
||||||
|
val db = mongoClient.getDatabase("my-db1")
|
||||||
|
|
||||||
|
for (i <- 1 to 100) {
|
||||||
|
val col = db.getCollection(s"col$i")
|
||||||
|
col.insertOne(Document("{field1:12}")).toFuture()
|
||||||
|
//Await.result(f1, 1.second)
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(5000)
|
||||||
|
|
||||||
|
//mongoClient.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
103
src/main/scala/eu/xeppaka/scalalearn/Main5.scala
Normal file
103
src/main/scala/eu/xeppaka/scalalearn/Main5.scala
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import java.util.Currency
|
||||||
|
|
||||||
|
import org.bson.{BsonReader, BsonWriter}
|
||||||
|
import org.bson.codecs.{Codec, DecoderContext, EncoderContext}
|
||||||
|
import org.mongodb.scala.MongoClient
|
||||||
|
import org.mongodb.scala.bson.codecs.Macros._
|
||||||
|
import org.mongodb.scala.bson.codecs.DEFAULT_CODEC_REGISTRY
|
||||||
|
import org.bson.codecs.configuration.CodecRegistries.{fromProviders, fromRegistries, fromCodecs}
|
||||||
|
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import scala.concurrent.Await
|
||||||
|
|
||||||
|
object Main5 {
|
||||||
|
sealed class EventData {
|
||||||
|
def idAccount: String = ???
|
||||||
|
}
|
||||||
|
case class Event(pid: String, sn: Long, data: EventData)
|
||||||
|
|
||||||
|
case class Value(v: Int)
|
||||||
|
case class AccountV1(override val idAccount: String, amount: Int, v: Value) extends EventData
|
||||||
|
case class AccountV2(override val idAccount: String, amount: Int) extends EventData
|
||||||
|
|
||||||
|
case class Class23(
|
||||||
|
field1: String = "field1",
|
||||||
|
field2: String = "field1",
|
||||||
|
field3: String = "field1",
|
||||||
|
field4: String = "field1",
|
||||||
|
field5: String = "field1",
|
||||||
|
field6: String = "field1",
|
||||||
|
field7: String = "field1",
|
||||||
|
field8: String = "field1",
|
||||||
|
field9: String = "field1",
|
||||||
|
field10: String = "field1",
|
||||||
|
field11: String = "field1",
|
||||||
|
field12: String = "field1",
|
||||||
|
field13: String = "field1",
|
||||||
|
field14: String = "field1",
|
||||||
|
field15: String = "field1",
|
||||||
|
field16: String = "field1",
|
||||||
|
field17: String = "field1",
|
||||||
|
field18: String = "field1",
|
||||||
|
field19: String = "field1",
|
||||||
|
field20: String = "field1",
|
||||||
|
field21: String = "field1",
|
||||||
|
field22: String = "field1",
|
||||||
|
field23: String = "field1",
|
||||||
|
field24: String = "field1",
|
||||||
|
field25: String = "field1",
|
||||||
|
field26: String = "field1",
|
||||||
|
field27: String = "field1",
|
||||||
|
field28: String = "field1",
|
||||||
|
field29: String = "field1",
|
||||||
|
field30: String = "field1",
|
||||||
|
field31: String = "field1"
|
||||||
|
) extends EventData
|
||||||
|
|
||||||
|
class ValueCodec extends Codec[Value] {
|
||||||
|
override def decode(reader: BsonReader, decoderContext: DecoderContext): Value = Value(reader.readInt32())
|
||||||
|
override def encode(writer: BsonWriter, value: Value, encoderContext: EncoderContext): Unit = writer.writeInt32(value.v)
|
||||||
|
override def getEncoderClass: Class[Value] = classOf[Value]
|
||||||
|
}
|
||||||
|
|
||||||
|
class CurrencyCodec extends Codec[Currency] {
|
||||||
|
override def decode(reader: BsonReader, decoderContext: DecoderContext): Currency = Currency.getInstance(reader.readString())
|
||||||
|
override def encode(writer: BsonWriter, value: Currency, encoderContext: EncoderContext): Unit = writer.writeString(value.getCurrencyCode)
|
||||||
|
override def getEncoderClass: Class[Currency] = classOf[Currency]
|
||||||
|
}
|
||||||
|
|
||||||
|
class Class23Codec extends Codec[Class23] {
|
||||||
|
override def encode(writer: BsonWriter, value: Class23, encoderContext: EncoderContext): Unit = {
|
||||||
|
writer.writeStartDocument()
|
||||||
|
writer.writeString("field1", value.field1)
|
||||||
|
writer.writeEndDocument()
|
||||||
|
}
|
||||||
|
override def decode(reader: BsonReader, decoderContext: DecoderContext): Class23 = {
|
||||||
|
reader.readStartDocument()
|
||||||
|
val field1 = reader.readString("field1")
|
||||||
|
reader.readEndDocument()
|
||||||
|
Class23(field1 = field1)
|
||||||
|
}
|
||||||
|
override def getEncoderClass: Class[Class23] = classOf[Class23]
|
||||||
|
}
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val codecRegistry = fromRegistries(fromCodecs(new ValueCodec, new CurrencyCodec, new Class23Codec), fromProviders(classOf[Event], classOf[EventData]), DEFAULT_CODEC_REGISTRY)
|
||||||
|
val client = MongoClient()
|
||||||
|
val db = client.getDatabase("hierarchy-test").withCodecRegistry(codecRegistry)
|
||||||
|
val accounts = db.getCollection[Event]("accounts")
|
||||||
|
val fieldColl = db.getCollection[Class23]("fields")
|
||||||
|
|
||||||
|
Await.result(fieldColl.insertOne(Class23()).toFuture(), 1.second)
|
||||||
|
// Await.result(accounts.insertOne(Event("001", 1, Class23())).toFuture(), 1.second)
|
||||||
|
// Await.result(accounts.insertOne(Event("001", 1, AccountV1("000001", 30, Value(10)))).toFuture(), 1.second)
|
||||||
|
// Await.result(accounts.insertOne(Event("001", 2, AccountV2("000002", 20, "EUR"))).toFuture(), 1.second)
|
||||||
|
|
||||||
|
val res = Await.result(accounts.find().toFuture(), 1.second)
|
||||||
|
res.foreach(println)
|
||||||
|
|
||||||
|
client.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/main/scala/eu/xeppaka/scalalearn/Main6.scala
Normal file
24
src/main/scala/eu/xeppaka/scalalearn/Main6.scala
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.actor.{ActorSystem, PoisonPill, Props}
|
||||||
|
import akka.stream.ActorMaterializer
|
||||||
|
import eu.xeppaka.scalalearn.ActorTest1.Print
|
||||||
|
|
||||||
|
import scala.concurrent.Await
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import scala.io.StdIn
|
||||||
|
|
||||||
|
object Main6 {
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val actorSystem = ActorSystem()
|
||||||
|
implicit val materializer: ActorMaterializer = ActorMaterializer()(actorSystem)
|
||||||
|
|
||||||
|
val actor = actorSystem.actorOf(Props(new ActorTest1))
|
||||||
|
actor ! Print
|
||||||
|
//actor ! PoisonPill
|
||||||
|
actor ! Print
|
||||||
|
|
||||||
|
StdIn.readLine()
|
||||||
|
Await.ready(actorSystem.terminate(), 5.seconds)
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/main/scala/eu/xeppaka/scalalearn/Main7.scala
Normal file
53
src/main/scala/eu/xeppaka/scalalearn/Main7.scala
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import org.bson.codecs.configuration.{CodecProvider, CodecRegistry}
|
||||||
|
import org.mongodb.scala.bson.codecs.Macros._
|
||||||
|
import org.bson.codecs.configuration.CodecRegistries.{fromCodecs, fromProviders, fromRegistries}
|
||||||
|
import org.bson.codecs.{Codec, DecoderContext, EncoderContext}
|
||||||
|
import org.bson.{BsonReader, BsonWriter}
|
||||||
|
import org.mongodb.scala.MongoClient
|
||||||
|
import org.mongodb.scala.bson.codecs.DEFAULT_CODEC_REGISTRY
|
||||||
|
import scalapb.{GeneratedEnum, GeneratedEnumCompanion}
|
||||||
|
|
||||||
|
import scala.concurrent.Await
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import scala.reflect._
|
||||||
|
|
||||||
|
object Main7 {
|
||||||
|
class ProtoEnumCodecProvider extends CodecProvider {
|
||||||
|
override def get[T](clazz: Class[T], registry: CodecRegistry): Codec[T] = {
|
||||||
|
val ass = classOf[GeneratedEnum].isAssignableFrom(clazz)
|
||||||
|
if (ass) {
|
||||||
|
new ProtoEnumCodec(clazz.asInstanceOf[Class[GeneratedEnum]]).asInstanceOf[Codec[T]]
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProtoEnumCodec(clazz: Class[GeneratedEnum]) extends Codec[GeneratedEnum] {
|
||||||
|
override def decode(reader: BsonReader, decoderContext: DecoderContext): GeneratedEnum = {
|
||||||
|
val method = clazz.getDeclaredMethod("fromName", classOf[String])
|
||||||
|
method.invoke(clazz, reader.readString()).asInstanceOf[Option[GeneratedEnum]].get
|
||||||
|
}
|
||||||
|
override def encode(writer: BsonWriter, value: GeneratedEnum, encoderContext: EncoderContext): Unit = writer.writeString(value.name)
|
||||||
|
override def getEncoderClass: Class[GeneratedEnum] = clazz
|
||||||
|
}
|
||||||
|
|
||||||
|
case class UseEnum(
|
||||||
|
status1: Status,
|
||||||
|
status2: Status
|
||||||
|
)
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val codecRegistry = fromRegistries(fromProviders(classOf[UseEnum], new ProtoEnumCodecProvider), DEFAULT_CODEC_REGISTRY)
|
||||||
|
val client = MongoClient()
|
||||||
|
val db = client.getDatabase("classtag-test").withCodecRegistry(codecRegistry)
|
||||||
|
val status = db.getCollection[UseEnum]("statuses")
|
||||||
|
|
||||||
|
//Await.result(status.insertOne(UseEnum(Status.OPEN, Status.BLOCKED_ALL)).toFuture(), 1.second)
|
||||||
|
//Await.result(status.insertOne(Status.BLOCKED_ALL).toFuture(), 1.second)
|
||||||
|
val res = Await.result(status.find().toFuture(), 1.second)
|
||||||
|
println(res.head.status1)
|
||||||
|
}
|
||||||
|
}
|
||||||
40
src/main/scala/eu/xeppaka/scalalearn/Main8.scala
Normal file
40
src/main/scala/eu/xeppaka/scalalearn/Main8.scala
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import akka.NotUsed
|
||||||
|
import akka.actor.ActorSystem
|
||||||
|
import akka.stream.scaladsl.{Sink, Source}
|
||||||
|
import akka.stream.{ActorMaterializer, Materializer}
|
||||||
|
|
||||||
|
import scala.concurrent.Future
|
||||||
|
import scala.io.StdIn
|
||||||
|
import scala.util.Random
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
object Main8 {
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
implicit val actorSystem: ActorSystem = ActorSystem()
|
||||||
|
implicit val materializer: Materializer = ActorMaterializer()
|
||||||
|
|
||||||
|
Source
|
||||||
|
.repeat(NotUsed)
|
||||||
|
.throttle(10, 1.second)
|
||||||
|
.mapAsync(1) { _ =>
|
||||||
|
Future.successful(Random.nextInt())
|
||||||
|
}
|
||||||
|
.mapAsync(1) { _ =>
|
||||||
|
Future.successful(Random.nextInt())
|
||||||
|
}
|
||||||
|
.flatMapConcat { i =>
|
||||||
|
if (i % 2 == 0) {
|
||||||
|
Source.empty
|
||||||
|
} else {
|
||||||
|
Source.single(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.to(Sink.foreach(println))
|
||||||
|
.run()
|
||||||
|
|
||||||
|
StdIn.readLine()
|
||||||
|
actorSystem.terminate()
|
||||||
|
}
|
||||||
|
}
|
||||||
39
src/main/scala/eu/xeppaka/scalalearn/Main9.scala
Normal file
39
src/main/scala/eu/xeppaka/scalalearn/Main9.scala
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import java.util.Currency
|
||||||
|
|
||||||
|
import org.bson.codecs.configuration.CodecRegistries.{fromCodecs, fromProviders, fromRegistries}
|
||||||
|
import org.bson.codecs.{Codec, DecoderContext, EncoderContext}
|
||||||
|
import org.bson.{BsonReader, BsonWriter}
|
||||||
|
import org.mongodb.scala.MongoClient
|
||||||
|
import org.mongodb.scala.bson.codecs.DEFAULT_CODEC_REGISTRY
|
||||||
|
import org.mongodb.scala.bson.codecs.Macros._
|
||||||
|
|
||||||
|
import scala.concurrent.Await
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
object Main9 {
|
||||||
|
case class Id(id: String)
|
||||||
|
case class Value(data: Int, text: String)
|
||||||
|
case class Data(values: Map[String, Value])
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
val codecRegistry = fromRegistries(fromProviders(classOf[Id], classOf[Value], classOf[Data]), DEFAULT_CODEC_REGISTRY)
|
||||||
|
val client = MongoClient()
|
||||||
|
val db = client.getDatabase("db-0002").withCodecRegistry(codecRegistry)
|
||||||
|
val coll = db.getCollection[Data]("coll-0001")
|
||||||
|
|
||||||
|
val d = Data(Map("111" -> Value(1, "111"), "222" -> Value(2, "222")))
|
||||||
|
//Await.result(coll.insertOne(d).toFuture(), 2.seconds)
|
||||||
|
|
||||||
|
// Await.result(fieldColl.insertOne(Class23()).toFuture(), 1.second)
|
||||||
|
// Await.result(accounts.insertOne(Event("001", 1, Class23())).toFuture(), 1.second)
|
||||||
|
// Await.result(accounts.insertOne(Event("001", 1, AccountV1("000001", 30, Value(10)))).toFuture(), 1.second)
|
||||||
|
// Await.result(accounts.insertOne(Event("001", 2, AccountV2("000002", 20, "EUR"))).toFuture(), 1.second)
|
||||||
|
|
||||||
|
val res = Await.result(coll.find().toFuture(), 1.second)
|
||||||
|
res.foreach(println)
|
||||||
|
|
||||||
|
client.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
6
src/main/scala/eu/xeppaka/scalalearn/TestMirror.scala
Normal file
6
src/main/scala/eu/xeppaka/scalalearn/TestMirror.scala
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
trait TestMirror {
|
||||||
|
def print(s: String)
|
||||||
|
def print2(s: String)
|
||||||
|
}
|
||||||
26
src/test/scala/eu/xeppaka/scalalearn/TestStub.scala
Normal file
26
src/test/scala/eu/xeppaka/scalalearn/TestStub.scala
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package eu.xeppaka.scalalearn
|
||||||
|
|
||||||
|
import org.scalamock.scalatest.MockFactory
|
||||||
|
import org.scalatest.{BeforeAndAfterEach, FlatSpec, OneInstancePerTest}
|
||||||
|
|
||||||
|
class TestStub extends FlatSpec with BeforeAndAfterEach with MockFactory with OneInstancePerTest {
|
||||||
|
var testMirror: TestMirror = _
|
||||||
|
|
||||||
|
override def beforeEach(): Unit = {
|
||||||
|
testMirror = stub[TestMirror]
|
||||||
|
(testMirror.print(_: String)).when(*).onCall { s: String => println(s"stub call: $s") }
|
||||||
|
}
|
||||||
|
|
||||||
|
"blah1" should "blah" in {
|
||||||
|
testMirror.print("123")
|
||||||
|
testMirror.print2("123")
|
||||||
|
(testMirror.print(_: String)).verify(*).once()
|
||||||
|
(testMirror.print2(_: String)).verify(*).once()
|
||||||
|
}
|
||||||
|
|
||||||
|
"blah2" should "blah" in {
|
||||||
|
testMirror.print("456")
|
||||||
|
testMirror.print("567")
|
||||||
|
(testMirror.print(_: String)).verify(*).twice()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user