Skip to content

Commit

Permalink
chore: Refactor client (#1711)
Browse files Browse the repository at this point in the history
Extracted out refactoring from
#1630

~~Had to also add a `subscribeSync` method on `ShapeStream` otherwise we
cannot guarantee that `Shape` is up to date when the stream is up to
date, since the processing is done asynchronously. We have three
options:~~
~~1. We re-introduce the `PromiseOr` abstractions in order for the
single `subscribe` call to handle both sync and async~~
~~2. We introduce an explicit `subcsribeSync` like I have done here,
which provides strong guarantees on up-to-date synchronicity~~
~~3. We change `Shape` to maintain it's own "up to date" logic as it is
not guaranteed that when the stream is up to date that the `Shape` will
have materialized its local state fully, since processing is async~~


Reintroduced thin version of sync + async handling in the queue to
maintain the current API and intended behaviour.

I've discussed with @kevin-dp and we think that actually making the
processing callbacks create backpressure on the stream rather than the
stream collecting the responses non-stop might be a better API and allow
the developers to choose the pace at which the stream will collect data
through the choice of processing callback. Will open a new PR for this,
so we can merge this one with the refactor.
  • Loading branch information
msfstef authored Sep 17, 2024
1 parent 5e72067 commit 9992a74
Show file tree
Hide file tree
Showing 20 changed files with 1,080 additions and 468 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-hornets-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@electric-sql/client": patch
---

Client refactor and fix `Shape` state synchronization with `ShapeStream`.
Loading

0 comments on commit 9992a74

Please sign in to comment.