Skip to content
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

feat(webserver): implement new storage layer for repository meta #1750

Closed
wants to merge 17 commits into from

Conversation

boxbeam
Copy link
Contributor

@boxbeam boxbeam commented Apr 1, 2024

Relates to TAB-533

@boxbeam boxbeam requested a review from wsxiaoys April 1, 2024 21:50
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 0.68027% with 146 lines in your changes are missing coverage. Please review.

Project coverage is 53.17%. Comparing base (837e36d) to head (cd19700).
Report is 1 commits behind head on main.

Files Patch % Lines
ee/tabby-webserver/src/repositories/resolve.rs 0.00% 83 Missing ⚠️
ee/tabby-webserver/src/hub/api.rs 0.00% 21 Missing ⚠️
crates/tabby-scheduler/src/dataset.rs 0.00% 16 Missing ⚠️
ee/tabby-webserver/src/repositories/mod.rs 0.00% 6 Missing ⚠️
ee/tabby-webserver/src/service/repository.rs 0.00% 6 Missing ⚠️
ee/tabby-webserver/src/handler.rs 0.00% 5 Missing ⚠️
crates/tabby-scheduler/src/lib.rs 0.00% 4 Missing ⚠️
ee/tabby-webserver/src/path.rs 0.00% 3 Missing ⚠️
ee/tabby-webserver/src/cron/mod.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1750      +/-   ##
==========================================
- Coverage   53.71%   53.17%   -0.54%     
==========================================
  Files         115      116       +1     
  Lines        9928     9976      +48     
==========================================
- Hits         5333     5305      -28     
- Misses       4595     4671      +76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@boxbeam boxbeam changed the title Begin implementing db for RepositoryMeta feat: Implement new db for repository meta Apr 2, 2024
@boxbeam boxbeam marked this pull request as ready for review April 3, 2024 21:13
@wsxiaoys wsxiaoys changed the title feat: Implement new db for repository meta feat(webserver): Implement new storage layer for repository meta Apr 5, 2024
ee/tabby-db/Cargo.toml Outdated Show resolved Hide resolved
ee/tabby-db/schema.sqlite Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@wsxiaoys wsxiaoys marked this pull request as draft April 5, 2024 05:23
@boxbeam boxbeam force-pushed the repository-meta-db branch from 71faf5b to 51d5512 Compare April 5, 2024 15:03
@boxbeam boxbeam marked this pull request as ready for review April 5, 2024 15:06
@wsxiaoys wsxiaoys marked this pull request as draft April 5, 2024 15:19
@wsxiaoys wsxiaoys changed the title feat(webserver): Implement new storage layer for repository meta feat(webserver): implement new storage layer for repository meta Apr 5, 2024
@boxbeam boxbeam force-pushed the repository-meta-db branch from 28c788f to f6dce73 Compare April 5, 2024 15:36
@boxbeam boxbeam force-pushed the repository-meta-db branch from 2b579c3 to 323a3c7 Compare April 5, 2024 16:02
@boxbeam boxbeam marked this pull request as ready for review April 5, 2024 16:04
let mut repository_lookup = self.repository_lookup.write().unwrap();
debug!("Reloading repositoriy metadata...");
*repository_lookup = load_meta(new_repositories);
pub fn latest_version(&self) -> Result<u64> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn latest_version(&self) -> Result<u64> {
fn latest_version(&self) -> Result<u64> {

Comment on lines +42 to +45
let bucket: Bucket<_, String> = self.cache.bucket(Some(META_BUCKET))?;
if !bucket.contains(&META_BUCKET_VERSION_KEY.to_string())? {
self.update_latest_version(self.get_next_version()?)?;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let bucket: Bucket<_, String> = self.cache.bucket(Some(META_BUCKET))?;
if !bucket.contains(&META_BUCKET_VERSION_KEY.to_string())? {
self.update_latest_version(self.get_next_version()?)?;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there's no latest version, it means the storage is simply empty.

@wsxiaoys wsxiaoys marked this pull request as draft April 5, 2024 16:20
type RepositoryBucket<'a> = Bucket<'a, String, kv::Json<RepositoryMeta>>;

static META_BUCKET: &str = "meta";
static META_BUCKET_VERSION_KEY: &str = "version";

impl RepositoryCache {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please review visibility of functions in this struct.

@boxbeam boxbeam closed this Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants