Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

contain serialization to the IO classes

  • Loading branch information...
commit 7eb108bf99b0c63c7bfd69a1c06396af552210d6 1 parent 3da5afe
@benmur authored
View
14 src/main/scala/net/benmur/riemann/client/ReliableIO.scala
@@ -36,11 +36,11 @@ trait ReliableIO {
}
}
- implicit object ReliableEventPartSendAndExpectFeedback extends SendAndExpectFeedback[EventPart, Boolean, Reliable] {
+ implicit object ReliableEventPartSendAndExpectFeedback extends SendAndExpectFeedback[EventPart, Boolean, Reliable] with Serializers {
def send(connection: Connection[Reliable], command: Write[EventPart])(implicit system: ActorSystem, timeout: Timeout): Future[Boolean] =
connection match {
case rc: ReliableConnection =>
- val data = Serializers.serializeEventPartToProtoMsg(command.m).toByteArray
+ val data = serializeEventPartToProtoMsg(command.m).toByteArray
(rc.ioActor ask WriteBinary(data)).mapTo[Proto.Msg] map (_.getOk)
case c =>
@@ -48,22 +48,22 @@ trait ReliableIO {
}
}
- implicit object ReliableQuerySendAndExpectFeedback extends SendAndExpectFeedback[Query, Iterable[EventPart], Reliable] {
+ implicit object ReliableQuerySendAndExpectFeedback extends SendAndExpectFeedback[Query, Iterable[EventPart], Reliable] with Serializers {
def send(connection: Connection[Reliable], command: Write[Query])(implicit system: ActorSystem, timeout: Timeout): Future[Iterable[EventPart]] =
connection match {
case rc: ReliableConnection =>
- val data = Serializers.serializeQueryToProtoMsg(command.m).toByteArray
- (rc.ioActor ask WriteBinary(data)).mapTo[Proto.Msg] map (Serializers.unserializeProtoMsg(_))
+ val data = serializeQueryToProtoMsg(command.m).toByteArray
+ (rc.ioActor ask WriteBinary(data)).mapTo[Proto.Msg] map (unserializeProtoMsg(_))
case c =>
Promise.failed(RemoteError("don't know how to send data to " + c.getClass.getName))
}
}
- implicit object ReliableSendOff extends SendOff[EventPart, Reliable] {
+ implicit object ReliableSendOff extends SendOff[EventPart, Reliable] with Serializers {
def sendOff(connection: Connection[Reliable], command: Write[EventPart]): Unit = connection match {
case rc: ReliableConnection =>
- rc.ioActor tell WriteBinary(Serializers.serializeEventPartToProtoMsg(command.m).toByteArray)
+ rc.ioActor tell WriteBinary(serializeEventPartToProtoMsg(command.m).toByteArray)
case c =>
System.err.println(
"don't know how to send data to " + c.getClass.getName)
View
1  src/main/scala/net/benmur/riemann/client/RiemannClient.scala
@@ -6,7 +6,6 @@ import akka.util.Timeout
object RiemannClient
extends EventDSL
with EventSenderDSL
- with Serializers
with ReliableIO
with UnreliableIO
with DestinationOps {
View
2  src/main/scala/net/benmur/riemann/client/Serializers.scala
@@ -58,5 +58,3 @@ trait Serializers {
Some(e.getMetricSint64)
else None
}
-
-object Serializers extends Serializers
View
4 src/main/scala/net/benmur/riemann/client/UnreliableIO.scala
@@ -20,10 +20,10 @@ trait UnreliableIO {
val ioActor = system.actorOf(props, "riemann-udp-client-" + nClients.incrementAndGet)
}
- implicit object UnreliableSendOff extends SendOff[EventPart, Unreliable] {
+ implicit object UnreliableSendOff extends SendOff[EventPart, Unreliable] with Serializers {
def sendOff(connection: Connection[Unreliable], command: Write[EventPart]): Unit = connection match {
case uc: UnreliableConnection =>
- val data = Serializers.serializeEventPartToProtoMsg(command.m).toByteArray
+ val data = serializeEventPartToProtoMsg(command.m).toByteArray
uc.ioActor tell WriteBinary(data)
case c => System.err.println("don't know how to send data to " + c.getClass.getName)
}
View
1  src/test/scala/net/benmur/riemann/client/SerializersTest.scala
@@ -6,6 +6,7 @@ import com.aphyr.riemann.Proto
import org.scalatest.matchers.ShouldMatchers
class SerializersTest extends FunSuite with ShouldMatchers {
+ object Serializers extends Serializers
import Serializers._
import testingsupport.SerializersFixture._
Please sign in to comment.
Something went wrong with that request. Please try again.