-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce an access mode for SQLite storage #511
Conversation
I'm not sure about deprecating the I'm open to other ideas for how to add a read-only mode in a backward-compatible fashion, or suggestions to just go to 2.0.0. |
Oops, I guess even this is a breaking change. That type probably shouldn't have been exposed to begin with! Maybe I should take a hard look at the API and make a 2.0.0 with a bunch of API fixes. |
a73c1ee
to
17b90ca
Compare
src/storage/config.rs
Outdated
}, | ||
/// Store the data in memory. This is only useful for testing. | ||
InMemory, | ||
} | ||
|
||
#[allow(deprecated)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? From your PR comments I'm under the impression you were going to deprecate something and then changed your mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks, I missed this one!
The storage implementation checks this access mode for all methods, but also opens SQLite in read-only mode when appropriate, which causes SQLite to skip creating a WAL log or updating the access time in the database. As a concession to ease-of-use with a new task database, the database is opened in read-write mode and the schema set up if it does not exist, regardless of the passed `AccessMode`. This is a breaking change because: - The publicly-visible method `SqliteStorage::new` now takes a different number of parameters. - The public enum `StorageConfig` has been marked #[non_exhaustive]. Pattern-matching on it outside of its crate must now include a wildcard pattern like `_`, or it will fail to compile. - `StorageConfig::OnDisk` has an additional field, `access_mode`, which has to be included when constructing or matching on this variant.
The storage implementation checks this access mode for all methods, but also opens SQLite in read-only mode when appropriate, which causes SQLite to skip creating a WAL log or updating the access time in the database.
As a concession to ease-of-use with a new task database, the database is opened in read-write mode and the schema set up if it does not exist, regardless of the passed
AccessMode
.This is a breaking change because:
SqliteStorage::new
now takes adifferent number of parameters.
StorageConfig
has been marked #[non_exhaustive].Pattern-matching on it outside of its crate must now include a
wildcard pattern like
_
, or it will fail to compile.StorageConfig::OnDisk
has an additional field,access_mode
, whichhas to be included when constructing or matching on this variant.
[edited to add the breaking-change justification]