This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="ProjectCodeStyleConfiguration"> | |
<code_scheme name="Project" version="173"> | |
<ScalaCodeStyleSettings> | |
<option name="NOT_CONTINUATION_INDENT_FOR_PARAMS" value="true" /> | |
<option name="USE_ALTERNATE_CONTINUATION_INDENT_FOR_PARAMS" value="true" /> | |
<option name="SPACES_IN_IMPORTS" value="true" /> | |
</ScalaCodeStyleSettings> | |
<codeStyleSettings language="Scala"> | |
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> | |
<option name="METHOD_PARAMETERS_WRAP" value="5" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun add-to-load-path (&rest paths) | |
(let (path) | |
(dolist (path paths paths) | |
(let ((default-directory (expand-file-name path))) | |
(add-to-list 'load-path default-directory) | |
(if (fboundp 'normal-top-level-add-subdirs-to-load-path) | |
(normal-top-level-add-subdirs-to-load-path)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent.Await | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext | |
import scala.concurrent.duration._ | |
import java.util.concurrent.Executors | |
object Service { | |
def calculate1(i: Int)(implicit ec: ExecutionContext) = Future{ for (n <- 1 to 10000) yield { n + i }; i } | |
def calculate2(i: Int)(implicit ec: ExecutionContext) = Future{ for (n <- 1 to 10000) yield { n + i } ; i * 2 } | |
def calculate3(i: Int)(implicit ec: ExecutionContext) = Future{ for (n <- 1 to 10000) yield { n + i } ; i + 2 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent.ExecutionContext.Implicits.global | |
import akka.agent.Agent | |
val agent = Agent(5) | |
// 状態変更 | |
agent send 10 | |
// 同期的に値を読み取る | |
val state1 = agent()// 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor._ | |
import scala.concurrent.duration._ | |
sealed trait State | |
case object Green extends State | |
case object Yellow extends State | |
case object Red extends State | |
case object FlashingYellow extends State |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait State | |
case object A extends State | |
case object B extends State | |
case object C extends State | |
case object OK | |
class StateMachine extends Actor { | |
var state: State = A | |
def receive = stateA | |
def stateA: Reicive = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package examples.akka.http.stack1 | |
import scala.concurrent.Await | |
import scala.concurrent.duration._ | |
import akka.actor.{Actor, ActorRef, ActorSystem, Props, Stash} | |
import akka.pattern.ask | |
import akka.util.Timeout | |
object ResultStreamIteratorApp extends App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object FileUtils { | |
case class SplitContext( | |
implicit executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global, | |
charset: Charset = Charset.forName("UTF-8"), | |
openOptions: Seq[OpenOption] = Seq(StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)) | |
def split(file: Path, outDir: Path, size: Int)(implicit splitContext: SplitContext = SplitContext()): Future[Iterator[Path]] = { | |
import splitContext.executionContext | |
implicit val codec = Codec(splitContext.charset) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akka.loglevel = "DEBUG" | |
akka.event-handlers = ["akka.event.slf4j.Slf4jEventHandler"] | |
akka.actor.debug.autoreceive = on | |
akka.actor.debug.lifecycle = on | |
akka.actor.debug.receive = on | |
akka.actor.debug.event-stream = on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// これはできない。 | |
val client = system.actorOf(ClusterClient.props(initialContacts = initialContacts)) | |
client ? ClusterClient.Send("/ping", "ping") |