Created
July 20, 2024 13:03
-
-
Save Vistritium/e87bcbc0442b2fe7a0835e1606d05fc5 to your computer and use it in GitHub Desktop.
This file contains 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
def pipeThroughInputStream(pipeThrough: InputStream => InputStream)(implicit mat: Materializer): Flow[ByteString, ByteString, NotUsed] = { | |
Flow.lazyFlow { () => | |
val sink = StreamConverters.asInputStream(5.minutes) | |
val (is, matSink) = sink.preMaterialize() | |
val source = StreamConverters.fromInputStream(() => pipeThrough(is)) | |
Flow.fromSinkAndSource(matSink, source) | |
}.mapMaterializedValue(f => | |
f.onComplete { | |
case Failure(exception) => logger.error("error", exception) | |
case Success(value) => | |
} | |
akka.NotUsed | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment