khonsulabs / bonsaidb

A developer-friendly document database that grows with you, written in Rust
https://bonsaidb.io/
Apache License 2.0
1.01k stars 37 forks source link

Add "colored" types for bonsaidb-client #253

Closed ecton closed 1 year ago

ecton commented 2 years ago

My original choice of having Client implement AsyncStorageConnection and StorageConnection caused a user to spend extra time debugging a problem due to a deadlock caused by using a call from StorageConnection in an async context. The local and server crates actively prevent this by having types that don't implement both traits.

We should add four new types: RemoteServer, AsyncRemoteServer, RemoteDatabase, AsyncRemoteDatabase. Each of these types should only implement one set of traits. Easy functions to convert between the types should be supported. Internally, these all should just wrap Client.

Additional builder methods can be provided to immediately return a specific type -- e.g., build_async()