Skip to content

Instantly share code, notes, and snippets.

@muller
Created December 28, 2016 12:12
Show Gist options
  • Save muller/e42080cc2c96e2b016d059aa3af792dc to your computer and use it in GitHub Desktop.
Save muller/e42080cc2c96e2b016d059aa3af792dc to your computer and use it in GitHub Desktop.
class CustomStage extends GraphStage[FlowShape[ByteString, ByteString]] {
val in = Inlet[ByteString]("CustomStage.in")
val out = Outlet[ByteString]("CustomStage.out")
override val shape = FlowShape.of(in, out)
override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler with OutHandler {
setHandlers(in, out, this)
override def onPush() = emit(out, grab(in))
override def onPull() = pull(in)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment