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
/** | |
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com> | |
*/ | |
package http | |
import java.util.concurrent.atomic.AtomicInteger | |
import akka.actor.{Actor, ActorRef, ActorSystem, Props} | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.model.{HttpResponse, StatusCodes, Uri} |
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.ActorSystem | |
import akka.stream._ | |
import akka.stream.scaladsl._ | |
import scala.io.StdIn | |
import scala.util.Random | |
object SimplePartitionSample extends App { | |
implicit val system = ActorSystem() |
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.ActorSystem | |
import akka.stream.scaladsl.Flow | |
import akka.stream.scaladsl.Tcp | |
import akka.util.ByteString | |
object TcpServerOneResponseThenComplete2 { | |
def main(args: Array[String]): Unit = { | |
implicit val system = ActorSystem() | |
import akka.stream.scaladsl.Framing |
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.ActorSystem | |
import akka.stream.scaladsl.Flow | |
import akka.stream.scaladsl.Tcp | |
import akka.util.ByteString | |
object TcpServerOneResponseThenComplete { | |
def main(args: Array[String]): Unit = { | |
implicit val system = ActorSystem() | |
import akka.stream.scaladsl.Framing |
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 java.util.UUID | |
import akka.actor.ActorSystem | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.model.HttpRequest | |
import akka.http.scaladsl.model.headers.{ModeledCustomHeader, ModeledCustomHeaderCompanion} | |
import akka.stream.ActorMaterializer | |
import akka.http.scaladsl.server._ | |
import scala.io.StdIn |
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.ActorSystem | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.marshalling.{Marshaller, ToResponseMarshaller} | |
import akka.http.scaladsl.model.HttpEntity.ChunkStreamPart | |
import akka.http.scaladsl.model.{HttpEntity, HttpResponse, MediaTypes} | |
import akka.http.scaladsl.server.Directives._ | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.Source | |
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
class MyActor extends AbstractActor { | |
public Receive createReceive() { | |
return receiveBuilder() | |
.match(Request.class, this::onRequest) | |
.build(); | |
} | |
private void onRequest(Request request) { | |
ActorRef child = createChildForRequest(request); |
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.{Actor, ActorLogging, ActorRef, ActorSystem, Props} | |
import akka.cluster.{Cluster, MemberStatus} | |
import akka.routing.FromConfig | |
import com.typesafe.config.ConfigFactory | |
object ClusterRouting extends App { | |
class EchoActor extends Actor with ActorLogging { | |
log.info("Started") | |
def receive = { |
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.{Actor, ActorLogging, ActorSystem, Props} | |
import akka.cluster.Cluster | |
import akka.routing.FromConfig | |
import com.typesafe.config.ConfigFactory | |
import scala.concurrent.{Await, Future} | |
import scala.io.StdIn | |
object ClusteredRoundRobinPool 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
import akka.actor.ActorSystem | |
import akka.http.scaladsl.unmarshalling.Unmarshal | |
import akka.stream.ActorMaterializer | |
import scala.concurrent.Await | |
// important - it needs to be this Seq and not the default one | |
import scala.collection.immutable.Seq | |
// this is just for the await, so not really needed | |
import scala.concurrent.duration._ |
NewerOlder