Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1367

Using Flow as Sink/Source

$
0
0

Hi All,

I’m having a bit of difficulty combining some akka-streams components. The goal is to be able to return a Sink[ByteString, _] that other components can use, but I’ve been unable to figure out how to expose the source and sink sides of a flow correctly. My code is roughly as follows:

def getOutbound(): Future[Sink[ByteString, _]] = {
  Sink.fromMaterializer { (mat, attr) =>
    Sink.futureSink {
      val flow = Flow[ByteString]
      val source = Source.fromGraph(flow) // this is incorrect

      val create = for {
        thing <- Marshal(source).to[RequestEntity] // need to provide Source[ByteString, _]
        // make http request
      } yield {
        Sink.fromGraph(flow) // this is incorrect
      }
    }
  }
}

Can anyone give me some pointers on the correct way to do this? My gut feel is that it shouldn’t require anything exotic, but what I really want to do is treat the HTTP request marshaller as a sink so that I can just say something like Flow[ByteString].to(myOutboundRequest).

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1367

Trending Articles