sqlite_async.dart icon indicating copy to clipboard operation
sqlite_async.dart copied to clipboard

Expose connection for workers

Open simolus3 opened this issue 1 year ago • 0 comments

This adds the exposeEndpoint() method on the web, which returns a record of values that can be sent across workers on the web. It also adds a new method that takes this sent record to open another database connection to the same source, which then shares the existing connection and mutex.

This is useful to allow a worker to connect to a database already opened by a client, such as for the sync worker in the Powersync SDK. A remaining issue is related to lifetimes: When the original connection closes and disposes the worker, the exposed endpoint will also close. sqlite3_web internally uses web locks to detect this condition, but it's not yet exposed in this package.

simolus3 avatar Sep 18 '24 20:09 simolus3