chore: Refactor ReplicationClient into a state machine #247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Seeing how the setup code in
Electric.Postgres.ReplicationClient
has been getting more complicated, I've made an attempt to refactor it into a separate module to make it clear which query follows which before the connection is switched into the logical streaming mode.In the end I have to say, that the amount of boilerplate has exceed my expectations, not in a good way. Still, I would like another person's opinion on whether this change makes it easier to reason about the replication client and its two operating modes: 1) connection setup and 2) logical streaming.
Ideally, I would have loved to use e.g.
epgsql
for the connection setup, then pass the connection socket over toPostgrex.ReplicationConnection
for streaming. That would have made the code much simpler.