I'm trying to write some code as part of a larger integration test.
I have a function that creates a KinesisSource
of type Source[KinesisRecord, Future[Done]
:
protected def createKinesisSource(config: KinesisClientLibConfiguration): Source[KinesisRecord, Future[Done]]#Repr[MyFile.KinesisFlow] = {
KinesisSource(config).mapAsync(1)(processRecord)
}
protected def processRecord(record: KinesisRecord): Future[KinesisFlow] = {
Future { validateRecord(record) }
}
I want to create a fake source of the same type from a file. I have (pardon the code, I'm new to scala):
val records = scala.io.Source.fromFile("testFile.txt").getLines.toList
.map(i => {
new KinesisRecord( ByteString.fromString(i), "x", None, "x", None, Instant.now(), "x")
})
Source(records).mapAsync(1)(processRecord)
That gives me a Source[KinesisRecord, NotUsed]
. How can I change that to Source[KinesisRecord, Future[Done]]
? I understand that the second parameter is the materialized value (see this post), but I'm not sure how to specify that value without actually applying a run
function.