superfly / litefs

FUSE-based file system for replicating SQLite databases across a cluster of machines
Apache License 2.0
3.96k stars 95 forks source link

Built-in Proxy #269

Closed benbjohnson closed 1 year ago

benbjohnson commented 1 year ago

Currently, applications that use LiteFS need to write some LiteFS-specific code to redirect requests to the primary and to maintain consistency with the TXID after a write. It'd be useful if LiteFS could provide its own thin HTTP proxy in front of the application that would do the following:

  1. Redirect non-GET requests to the primary node.
  2. Inject a cookie (or other mechanism) for tracking the current TXID after a write.
  3. Wait for a replica node to catch up to the client's tracked TXID.

With these features along with write forwarding (#56), most applications should not need to have any knowledge about LiteFS.

@kentcdodds Can you think of any other LiteFS-specific application code we could get rid of with a thin proxy?

kentcdodds commented 1 year ago

Yep! Those would remove almost all needs for the app to know about LiteFS. In case where writes need to happen for GETs (like updating a session expiration time), the application would need to replay. But the vast majority would be handled by what you've suggested. I'd love to have that.

Would probably be good to make some things comfortable (like the methods and maybe even URLs or something).

Thanks!