akka-http-phoenix


License

License

MIT
Categories

Categories

Akka Container Microservices Reactive libraries
GroupId

GroupId

io.taig
ArtifactId

ArtifactId

akka-http-phoenix_2.12
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

akka-http-phoenix
akka-http-phoenix
Project URL

Project URL

https://github.com/taig/akka-http-phoenix
Project Organization

Project Organization

io.taig
Source Code Management

Source Code Management

https://github.com/taig/akka-http-phoenix

Download akka-http-phoenix_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.taig/akka-http-phoenix_2.12/ -->
<dependency>
    <groupId>io.taig</groupId>
    <artifactId>akka-http-phoenix_2.12</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.taig/akka-http-phoenix_2.12/
implementation 'io.taig:akka-http-phoenix_2.12:1.0.0'
// https://jarcasting.com/artifacts/io.taig/akka-http-phoenix_2.12/
implementation ("io.taig:akka-http-phoenix_2.12:1.0.0")
'io.taig:akka-http-phoenix_2.12:jar:1.0.0'
<dependency org="io.taig" name="akka-http-phoenix_2.12" rev="1.0.0">
  <artifact name="akka-http-phoenix_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.taig', module='akka-http-phoenix_2.12', version='1.0.0')
)
libraryDependencies += "io.taig" % "akka-http-phoenix_2.12" % "1.0.0"
[io.taig/akka-http-phoenix_2.12 "1.0.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.1
com.typesafe.akka : akka-http_2.12 jar 10.0.0
io.circe : circe-core_2.12 jar 0.6.1
io.circe : circe-generic_2.12 jar 0.6.1
io.circe : circe-parser_2.12 jar 0.6.1

test (2)

Group / Artifact Type Version
org.tpolecat » tut-core_2.12 jar 0.4.7
org.scalatest : scalatest_2.12 jar 3.0.1

Project Modules

There are no modules declared in this project.

akka HTTP Phoenix

CircleCI codecov License

A simple implementation of (most of) the Phoenix Channels protocol with akka HTTP for WebSocket communication and circe for JSON

Installation

akka HTTP Phoenix is available for Scala 2.11 and 2.12

libraryDependencies += "io.taig" %% "akka-http-phoenix" % "1.0.0"

Usage

import akka.actor.ActorSystem
import akka.http.scaladsl.model.ws.WebSocketRequest
import akka.stream.ActorMaterializer
import io.circe.syntax._
import io.taig.akka.http.phoenix._

import scala.concurrent._
import scala.concurrent.duration._
import scala.language.postfixOps

implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()

val request = WebSocketRequest( "ws://localhost:4000/socket/websocket" )
val topic = Topic( "echo", "foobar" )

import system.dispatcher

val future = for {
    // Open socket connection to the Phoenix server
    phoenix  Phoenix( request )
    // Join a channel
    Right( channel )  phoenix.join( topic )
    // Send a message and wait for response
    Result.Success( response )  channel.send( Event( "echo" ), "foobar".asJson )
    // Shutdown socket connection from the client side
    _ = phoenix.close()
} yield response
scala> try {
     |     Await.result( future, 5 seconds )
     | } finally {
     |     Await.result( system.terminate(), 5 seconds )
     | }
res5: io.taig.akka.http.phoenix.message.Response =
Response(Topic(echo:foobar),Event(phx_reply),Some(Payload(Status(ok),{
  "payload" : "foobar"
})),Ref(1))

Test-Suite & Documentation

Code executed by the unit tests or documentation generation via tut requires the phoenix_echo app to be running in the background. Use the provided Dockerfile to create an image with pre-installed requirements.

Versions

Version
1.0.0