-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move kafka value context specific classes into package (#33)
* Remove unused imports * flatMap doesn't make sense in this context, removed. * Cleanup after testing in node ingestor
- Loading branch information
Showing
4 changed files
with
52 additions
and
6 deletions.
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
ft-coroutines-kafka/src/main/kotlin/tech/figure/kafka/context/AckedValue.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package tech.figure.kafka.context | ||
|
||
import tech.figure.kafka.records.AckedConsumerRecord | ||
|
||
data class AckedConsumerRecordValue<K, V, T>(val record: AckedConsumerRecord<K, V>, val value: T) { | ||
fun <R> map(block: (T) -> R): AckedConsumerRecordValue<K, V, R> = | ||
AckedConsumerRecordValue(record, block(value)) | ||
} |
18 changes: 18 additions & 0 deletions
18
ft-coroutines-kafka/src/main/kotlin/tech/figure/kafka/context/UnAckedValue.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package tech.figure.kafka.context | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import tech.figure.kafka.records.UnAckedConsumerRecord | ||
|
||
fun <K, V, T> UnAckedConsumerRecord<K, V>.withValue(t: T) = UnAckedConsumerRecordValue(this, t) | ||
|
||
fun <K, V, T> Flow<List<UnAckedConsumerRecordValue<K, V, T>>>.acking(): Flow<List<AckedConsumerRecordValue<K, V, T>>> = | ||
map { it.map { it.ack() } } | ||
|
||
data class UnAckedConsumerRecordValue<K, V, T>(val record: UnAckedConsumerRecord<K, V>, val value: T) { | ||
suspend fun ack(): AckedConsumerRecordValue<K, V, T> = | ||
AckedConsumerRecordValue(record.ack(), value) | ||
|
||
fun <R> map(block: (T) -> R): UnAckedConsumerRecordValue<K, V, R> = | ||
UnAckedConsumerRecordValue(record, block(value)) | ||
} |
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