kafka-flow
kafka-flow copied to clipboard
Reducing coupling with kafka-journal
As you may know from kafka-flow's overview, the library is tightly coupled with kafka-journal. But in reality, only the sources from the com.evolutiongaming.kafka.flow.journal package are involved in reading the journal.
kafka-flow is already used by many internal Evo apps to a great success, and a lot of them are reading generic kafka topics instead ofkafka-journal's journal.
Direct dependency on kafka-journal brings a lot of unnecessary, transient dependencies to classpath like akka, making the library much harder to use than it should be, and the path for migration to Scala 3 unclear. In many cases kafka-journal is just treated as a source of util classes that are not strictly related to the kafka-journal domain.
My suggestion would be to move code that is shared between kafka-journal and kafka-flow into separate libraries and modules.
In particular, we can:
1. Ensure binary and source compatibility is checked:
- [x] in
kafka-flow: https://github.com/evolution-gaming/kafka-flow/issues/593 - [x] in
scassandra: https://github.com/evolution-gaming/scassandra/issues/250 - [x] in
skafka: https://github.com/evolution-gaming/skafka/issues/420
2. kafka related
- [x] Use
ConsumerRecordandConsumerRecordsfrom skafka directly instead ofConsRecordandConsRecordsaliases - [ ] Extract to
skafka/ remove / internalize:- [x]
PartitionOffset - [ ]
KafkaHealthCheck - [x]
SkafkaHelper - [ ]
HeaderToTuple - [ ]
TupleToHeader
- [x]
3. cassandra related
- [ ] Extract to
scassandra/ remove / internalize:- [x]
CassandraSession - [ ]
CassandraHealthCheck - [ ]
Segments - [x]
CassandraHelper
- [x]
4. Extract to separate kafka-flow-journal and kafka-flow-journal-cassandramodules:
- [ ] all
*Journal*stuff withcom.evolutiongaming.kafka.flow.journalfromcoreandpersistence-cassandraIn the interim stage, these module could directly depend on thekafka-journal, but ideally types likeSeqNrorConsRecordwould be extracted to somekafka-journal-api, which would be a shared dependency betweenkafka-journalandkafka-flow-journal.
5. Extract to cats-helper or other helper libs or just remove:
- [ ]
RandomIdOf - [ ]
FromBytes - [ ]
ToBytes - [ ]
FromAttempt - [ ]
Fail- we could make a helper (extension) method forJournalError(a).raiseErrorand just useApplicativeThrowabledirectly instead - [ ]
FromJsResult(play-json util)