It's formally proven to be the strongest consistency model you can have for an AP system like this. But the result is basically for the user, it's just resilient to going in and out of network connectivity and the applications just keep functioning.
Now, with that, I mentioned some of this distributed systems, complexity you get with a kind of sync layer like this. This is a demo that's just showing you, for instance, how, as well as maintaining consistency of the data, so you always end up in the same state, we also preserve relational invariance.
So there's a classic example where this is where you have players who can enroll in tournaments, so you can basically enroll a tournament, and as you see, it syncs between the two devices. Now, what happens, for instance, if we disconnect user one, enroll a player in this second tournament here, whilst concurrently this user deletes the tournament, you basically have to have a way of preserving referential integrity. And for this demo, we use technical compensations, which means if that happens, the tournament gets recreated. So there's basically a whole bunch of clever stuff built into the sync layer, which is designed to maintain the sort of standard database level guarantees that you would have coding against a system, like say Prisma on the back end, or just coding against any database system, but we're basically allowing that to work even when you're doing these local writes, even in an offline mode.
And then just maybe just show one last thing. So it's active-active replication, right? So we've been showing basically interacting with the system through these widgets embedded into a web page. Basically, I'll open up a terminal here. And Windows v. Windows. So what we've got is basically the same kind of mini demo here, just embedded into the page. Again, this is all just live code.
You can see if I grab here, what we've got is some user-scoped PSQL credentials. So I can just connect directly to the Postgres database that's underpinning the system. Let's have a look here. There's some of these tables that were just underpinning the demos, players and tournaments, et cetera. And then if you go here, for instance, here's a command that I can enter into Postgres, which will just update the slider to a random position. And as you see, if I hit it, I can just basically keep moving the slider around.
So there's a few really interesting things here. One is that you can have your UE state in the database. So you have unified state management between your data and your UE state, which is actually quite a profound change in terms of simplifying the way you do application development. And also, meaning that you don't get kind of boundaries between those kind of different models between client state and sort of persisted data. Also, so it's bi-directional. So for instance, we just saw basically updating a record in the database and how it's reflected here. Equally, if I run this command to basically watch the slider value, you see that as I move the slide around in the browser, the value is updating in the database. So basically, you can see the bi-directional sync.
Comments