Skip to content

Commit c1f755c

Browse files
RajivTSfacebook-github-bot
authored andcommitted
Introduce Metadata Cache Config
Summary: Essentially the fbcode equivalent of D72857433. To be landed once the configerator diff has landed Reviewed By: lmvasquezg Differential Revision: D72862134 fbshipit-source-id: 6d7035015c938668ca47e9c79395d7687a7a1d0b
1 parent 8245831 commit c1f755c

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

configerator/structs/scm/mononoke/repos/repos.thrift

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @generated SignedSource<<8f8c9c9b9a7a0b180e962aabef6f7a1b>>
1+
// @generated SignedSource<<4264b9c6ce74f4599e6b42ba110fa093>>
22
// DO NOT EDIT THIS FILE MANUALLY!
33
// This file is a mechanical copy of the version in the configerator repo. To
44
// modify it, edit the copy in the configerator repo instead and copy it over by
@@ -305,6 +305,31 @@ struct RawRepoConfig {
305305
68: optional RawModernSyncConfig modern_sync_config;
306306
// Expose continuous stats about repo contents, this is for when mononoke server is the receiving end of a sync
307307
69: optional bool log_repo_stats;
308+
// Configuration controlling the caching mechanism used for different types of Mononoke metadata
309+
// (e.g. bookmarks, bonsai hash mappings, git symref mappings, etc.)
310+
70: optional RawMetadataCacheConfig metadata_cache_config;
311+
}
312+
313+
// Mode in which metadata cache updater tails the input category for updates
314+
struct RawTailing {
315+
// The scribe category to tail for bookmark updates
316+
1: string category;
317+
}
318+
// Mode in which metadata cache updater directly polls the XDB periodically for updates
319+
struct RawPolling {}
320+
321+
// Enum controlling how certain Mononoke metadata cache is updated
322+
union RawMetadataCacheUpdateMode {
323+
1: RawTailing tailing;
324+
2: RawPolling polling;
325+
}
326+
327+
// Configuration controlling the caching mechanism used for different types of Mononoke metadata
328+
// (e.g. bookmarks, bonsai hash mappings, git symref mappings, etc.)
329+
struct RawMetadataCacheConfig {
330+
1: optional RawMetadataCacheUpdateMode wbc_update_mode;
331+
2: optional RawMetadataCacheUpdateMode tags_update_mode;
332+
3: optional RawMetadataCacheUpdateMode content_refs_update_mode;
308333
}
309334

310335
// Configuration for connecting to Zelos

eden/mononoke/metaconfig/parser/src/config.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ fn parse_with_repo_definition(
245245
git_configs,
246246
modern_sync_config,
247247
log_repo_stats,
248+
metadata_cache_config,
248249
..
249250
} = named_repo_config;
250251

@@ -371,7 +372,9 @@ fn parse_with_repo_definition(
371372
let modern_sync_config = modern_sync_config.convert()?;
372373
let log_repo_stats = log_repo_stats.unwrap_or(false);
373374
let objects_count_multiplier = objects_count_multiplier.map(ObjectsCountMultiplier::new);
374-
375+
let metadata_cache_config = metadata_cache_config
376+
.map(|cache_config| cache_config.convert())
377+
.transpose()?;
375378
Ok(RepoConfig {
376379
enabled,
377380
storage_config,
@@ -425,6 +428,7 @@ fn parse_with_repo_definition(
425428
git_configs,
426429
modern_sync_config,
427430
log_repo_stats,
431+
metadata_cache_config,
428432
})
429433
}
430434

@@ -584,6 +588,8 @@ mod test {
584588
use metaconfig_types::LfsParams;
585589
use metaconfig_types::LocalDatabaseConfig;
586590
use metaconfig_types::LoggingDestination;
591+
use metaconfig_types::MetadataCacheConfig;
592+
use metaconfig_types::MetadataCacheUpdateMode;
587593
use metaconfig_types::MetadataDatabaseConfig;
588594
use metaconfig_types::MetadataLoggerConfig;
589595
use metaconfig_types::MultiplexId;
@@ -976,6 +982,10 @@ mod test {
976982
bookmarks = ["master", "release"]
977983
sleep_interval_secs = 100
978984
985+
[metadata_cache_config]
986+
wbc_update_mode = { tailing = { category = "scribe_category" } }
987+
tags_update_mode = { polling = {} }
988+
979989
[x_repo_sync_source_mapping.mapping.aros]
980990
bookmark_regex = "master"
981991
backsync_enabled = true
@@ -1423,6 +1433,13 @@ mod test {
14231433
},
14241434
modern_sync_config: None,
14251435
log_repo_stats: false,
1436+
metadata_cache_config: Some(MetadataCacheConfig {
1437+
wbc_update_mode: Some(MetadataCacheUpdateMode::Tailing {
1438+
category: "scribe_category".to_string(),
1439+
}),
1440+
tags_update_mode: Some(MetadataCacheUpdateMode::Polling),
1441+
content_refs_update_mode: None,
1442+
}),
14261443
},
14271444
);
14281445

@@ -1504,6 +1521,7 @@ mod test {
15041521
},
15051522
modern_sync_config: None,
15061523
log_repo_stats: false,
1524+
metadata_cache_config: None,
15071525
},
15081526
);
15091527
assert_eq!(

eden/mononoke/metaconfig/parser/src/convert/repo.rs

+41
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use std::collections::HashMap;
99

1010
use anyhow::anyhow;
11+
use anyhow::bail;
1112
use anyhow::Context;
1213
use anyhow::Result;
1314
use bookmarks_types::BookmarkKey;
@@ -38,6 +39,8 @@ use metaconfig_types::InfinitepushNamespace;
3839
use metaconfig_types::InfinitepushParams;
3940
use metaconfig_types::LfsParams;
4041
use metaconfig_types::LoggingDestination;
42+
use metaconfig_types::MetadataCacheConfig;
43+
use metaconfig_types::MetadataCacheUpdateMode;
4144
use metaconfig_types::MetadataLoggerConfig;
4245
use metaconfig_types::ModernSyncChannelConfig;
4346
use metaconfig_types::ModernSyncConfig;
@@ -90,6 +93,8 @@ use repos::RawInfinitepushParams;
9093
use repos::RawLfsParams;
9194
use repos::RawLoggingDestination;
9295
use repos::RawLoggingDestinationScribe;
96+
use repos::RawMetadataCacheConfig;
97+
use repos::RawMetadataCacheUpdateMode;
9398
use repos::RawMetadataLoggerConfig;
9499
use repos::RawModernSyncConfig;
95100
use repos::RawPushParams;
@@ -955,3 +960,39 @@ impl Convert for RawCommitCloudConfig {
955960
})
956961
}
957962
}
963+
964+
impl Convert for RawMetadataCacheUpdateMode {
965+
type Output = MetadataCacheUpdateMode;
966+
fn convert(self) -> Result<Self::Output> {
967+
let cache_update_mode = match self {
968+
RawMetadataCacheUpdateMode::tailing(tailing) => MetadataCacheUpdateMode::Tailing {
969+
category: tailing.category,
970+
},
971+
RawMetadataCacheUpdateMode::polling(_) => MetadataCacheUpdateMode::Polling,
972+
RawMetadataCacheUpdateMode::UnknownField(f) => {
973+
bail!("Unsupported MetadataCacheUpdateMode {}", f)
974+
}
975+
};
976+
Ok(cache_update_mode)
977+
}
978+
}
979+
980+
impl Convert for RawMetadataCacheConfig {
981+
type Output = MetadataCacheConfig;
982+
fn convert(self) -> Result<Self::Output> {
983+
Ok(MetadataCacheConfig {
984+
wbc_update_mode: self
985+
.wbc_update_mode
986+
.map(|mode| mode.convert())
987+
.transpose()?,
988+
tags_update_mode: self
989+
.tags_update_mode
990+
.map(|mode| mode.convert())
991+
.transpose()?,
992+
content_refs_update_mode: self
993+
.content_refs_update_mode
994+
.map(|mode| mode.convert())
995+
.transpose()?,
996+
})
997+
}
998+
}

eden/mononoke/metaconfig/types/src/lib.rs

+27
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ pub struct RepoConfig {
277277
pub modern_sync_config: Option<ModernSyncConfig>,
278278
/// Expose continuous stats about repo contents, this is for when mononoke server is the receiving end of a sync
279279
pub log_repo_stats: bool,
280+
/// Configuration controlling the caching mechanism used for different types of Mononoke metadata
281+
/// (e.g. bookmarks, bonsai hash mappings, git symref mappings, etc.)
282+
pub metadata_cache_config: Option<MetadataCacheConfig>,
280283
}
281284

282285
/// Config determining if the repo is deep sharded in the context of a service.
@@ -2077,3 +2080,27 @@ impl Deref for ObjectsCountMultiplier {
20772080
&self.0
20782081
}
20792082
}
2083+
2084+
/// Enum controlling how certain Mononoke metadata cache is updated
2085+
#[derive(Debug, Default, Clone, PartialEq, Eq)]
2086+
pub enum MetadataCacheUpdateMode {
2087+
/// Mode in which metadata cache updater tails the input category for updates
2088+
Tailing {
2089+
/// Scribe category to tail for updates
2090+
category: String,
2091+
},
2092+
/// Mode in which metadata cache updater directly polls the XDB periodically for updates
2093+
#[default]
2094+
Polling,
2095+
}
2096+
2097+
/// Configuration for Mononoke metadata cache
2098+
#[derive(Debug, Default, Clone, PartialEq, Eq)]
2099+
pub struct MetadataCacheConfig {
2100+
/// Mode for updating the warm bookmark metadata cache
2101+
pub wbc_update_mode: Option<MetadataCacheUpdateMode>,
2102+
/// Mode for updating the tags metadata cache
2103+
pub tags_update_mode: Option<MetadataCacheUpdateMode>,
2104+
/// Mode for updating the content refs metadata cache
2105+
pub content_refs_update_mode: Option<MetadataCacheUpdateMode>,
2106+
}

0 commit comments

Comments
 (0)