Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reducing coupling with kafka-journal #592

Open
8 of 22 tasks
grzegorz-bielski opened this issue Mar 25, 2024 · 0 comments
Open
8 of 22 tasks

Reducing coupling with kafka-journal #592

grzegorz-bielski opened this issue Mar 25, 2024 · 0 comments

Comments

@grzegorz-bielski
Copy link
Contributor

grzegorz-bielski commented Mar 25, 2024

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:

2. kafka related

  • Use ConsumerRecord and ConsumerRecords from skafka directly instead of ConsRecord and ConsRecords aliases
  • Extract to skafka / remove / internalize:
    • PartitionOffset
    • KafkaHealthCheck
    • SkafkaHelper
    • HeaderToTuple
    • TupleToHeader

3. cassandra related

  • Extract to scassandra / remove / internalize:
    • CassandraSession
    • CassandraHealthCheck
    • Segments
    • CassandraHelper

4. Extract to separate kafka-flow-journal and kafka-flow-journal-cassandramodules:

  • all *Journal* stuff with com.evolutiongaming.kafka.flow.journal from core and persistence-cassandra
    In the interim stage, these module could directly depend on the kafka-journal, but ideally types like SeqNr or ConsRecord would be extracted to some kafka-journal-api, which would be a shared dependency between kafka-journal and kafka-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 for JournalError(a).raiseError and just use ApplicativeThrowable directly instead
  • FromJsResult (play-json util)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant