-
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: keeper trait & sqlite-backed implementation #582
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
Open
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
12feec3
feat: keeper trait & sqlite-backed implementation
aldy505 df56bda
fix(doc): link error
aldy505 261c98a
fix(keeper): don't discard sql errors
aldy505 2ea15f1
chore: cleanup dependencies
aldy505 9309a88
ref: rework mark_accessed into update
aldy505 2a8235d
fix: AI code reviews
aldy505 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| CREATE TABLE IF NOT EXISTS ttl_keeper ( | ||
| object_id TEXT PRIMARY KEY, | ||
| expiration_policy INTEGER NOT NULL DEFAULT 0, | ||
| duration INTEGER, | ||
| time_created INTEGER NOT NULL, | ||
| time_expires INTEGER | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| //! Keeper defines a trait to support extending an object retention for backends | ||
| //! that does not support them natively (e.g., S3-compatible backend and filesystem). | ||
|
|
||
| use objectstore_types::metadata::ExpirationPolicy; | ||
|
|
||
| use crate::error::Result; | ||
| use crate::id::ObjectId; | ||
|
|
||
| /// SQLite-backed implementation of the [`Keeper`] trait. | ||
| pub mod sqlite_backed; | ||
|
|
||
| /// Represents the computed expiry information for an object. | ||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub struct ObjectExpiry<'a> { | ||
| id: &'a ObjectId, | ||
| expiration_policy: ExpirationPolicy, | ||
| } | ||
|
|
||
| /// Object retention keeper trait. | ||
| #[async_trait::async_trait] | ||
| pub trait Keeper: Send + Sync { | ||
| /// Keep is the first step in the object retention lifecycle. | ||
| /// Practically speaking, it would not be kept if the `expiration_policy` is `Manual`. | ||
| /// The `expiration_policy` is set by the client at upload time via the supplied Metadata. | ||
| async fn keep(&self, id: &ObjectId, expiration_policy: ExpirationPolicy) -> Result<()>; | ||
|
|
||
| /// Remove is the final step in the object retention lifecycle. | ||
| /// It is called by a cleanup worker when the object is no longer needed. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either this, or when the object is deleted per user request (or as part of tiered storage cleanup, but that's the same method). |
||
| async fn remove(&self, id: &ObjectId) -> Result<()>; | ||
|
|
||
| /// Update an object to a new expiration policy (and thus, new expiration time). | ||
| async fn update(&self, id: &ObjectId, expiration_policy: ExpirationPolicy) -> Result<()>; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we find a more descriptive name for this?
Keeperis a nice and short name, but it lacks context on what this is for.Intuitively, what we're building is GC, so I'm throwing that in as a suggestion.
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.
I took Zookeeper and ClickHouse Keeper as a reference for this 😄