This file contains hidden or 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.typed.patterns.Receiver._ | |
import akka.typed._ | |
import akka.typed.patterns.Receiver | |
import akka.typed.ScalaDSL._ | |
import scala.concurrent.duration._ | |
object AkkaTypedReceiver extends App { | |
sealed trait HelloMsg | |
final case class HelloCountry(country: String) extends HelloMsg |
This file contains hidden or 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.typed._ | |
import akka.typed.ScalaDSL._ | |
import akka.typed.AskPattern._ | |
import akka.util.Timeout | |
import scala.concurrent.Future | |
import scala.concurrent.duration._ | |
import scala.concurrent.Await | |
object AkkaTyped extends App { |
This file contains hidden or 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.{Props, ActorSystem, Actor} | |
import org.apache.commons.dbcp.{PoolingDataSource, DelegatingConnection} | |
import org.json4s.DefaultFormats | |
import org.postgresql.{PGNotification, PGConnection} | |
import scalikejdbc._ | |
import org.json4s.native.JsonMethods._ | |
import scala.concurrent.duration._ | |
/** |
This file contains hidden or 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
name := "postgresql-notifications" | |
version := "1.0" | |
scalaVersion := "2.11.7" | |
libraryDependencies ++= Seq("org.postgresql" % "postgresql" % "9.4-1200-jdbc41", | |
"org.scalikejdbc" %% "scalikejdbc" % "2.2.8", | |
"com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT", | |
"org.json4s" %% "json4s-native" % "3.2.10" |
This file contains hidden or 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
-- | |
CREATE OR REPLACE FUNCTION notify_event() RETURNS TRIGGER AS $$ DECLARE | |
data json; | |
notification json; | |
BEGIN | |
-- Convert the old or new row to JSON, based on the kind of action. | |
-- Action = DELETE? -> OLD row | |
-- Action = INSERT or UPDATE? -> NEW row |
This file contains hidden or 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 ReadSample extends App { | |
/** | |
* The readable trait defines how objects can be converted from a string | |
* representation to the objects instance. For most of the standard types | |
* we can simply use the toType function of String. | |
*/ | |
trait Readable[T] { | |
def read(x: String): T | |
} |
This file contains hidden or 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 scalaz._ | |
import Scalaz._ | |
/** | |
* Simple example showing how to use the reader pattern together with | |
* the Scalaz provided ValidationNel to apply validations in a functional | |
* easily extensible manner. | |
*/ | |
object ValidationSample extends App { |
This file contains hidden or 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.io.File | |
import akka.actor._ | |
import akka.routing.{Routee, RemoveRoutee, ActorRefRoutee, AddRoutee} | |
import akka.stream.actor.ActorPublisher | |
import org.akkamon.core.ActorStack | |
import org.akkamon.core.instruments.CounterTrait | |
import play.api.libs.json.Json | |
import scala.annotation.tailrec | |
import scala.concurrent.duration._ |
This file contains hidden or 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.io.File | |
import akka.actor._ | |
import akka.routing.{RemoveRoutee, ActorRefRoutee, AddRoutee} | |
import akka.stream.actor.ActorPublisher | |
import play.api.libs.json.Json | |
import scala.annotation.tailrec | |
import scala.concurrent.duration._ | |
/** |
This file contains hidden or 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.net.{SocketOptions, Inet4Address, InetAddress, Socket} | |
import java.util.concurrent.TimeoutException | |
import akka.actor.{ActorRef, Props, ActorSystem} | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.model.HttpMethods._ | |
import akka.http.scaladsl.model._ | |
import akka.http.scaladsl.model.ws._ | |
import akka.io.Inet | |
import akka.routing.BroadcastGroup |