surrealdb / surrealkv

A low-level, versioned, embedded, ACID-compliant, key-value database for Rust
https://surrealdb.com
Apache License 2.0
293 stars 18 forks source link

[store] Close the store asynchronously when it's dropped #31

Closed sgirones closed 7 months ago

sgirones commented 7 months ago

The store.close() method is async so it can't be directly called from fn drop().

This PR introduces a Store wrapper that handles the drop asynchronously.

There's the caveat that if the Store is dropped and then we immediately try to open it again, the original store may not be closed yet.

In order to overcome that, the user can explicitly close the store instead of relying on the drop.

The drop is mainly intended to handle the common scenario where the Store is dropped when the program exits.

sgirones commented 7 months ago

Absolutely. This one in isolation gives no guarantees, we need something else.

Having this though allows for implicit graceful shutdown.

@arriqaaq is going to work on improved durability of write operations