Skip to content

Commit 158e097

Browse files
committed
Fixup.
1 parent c8b3722 commit 158e097

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

nativelink-store/src/default_store_factory.rs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,38 @@ pub fn store_factory<'a>(
124124
store.clone().register_health(health_registry_builder);
125125
}
126126

127-
Ok(Store::new(MetricsStore::new(Arc::new(Store::new(store)), name, compute_store_type(backend))))
127+
let store = Store::new(store);
128+
129+
return if should_wrap_metrics_store(backend) {
130+
Ok(Store::new(MetricsStore::new(
131+
Arc::new(store),
132+
name,
133+
compute_store_type(backend),
134+
)))
135+
} else {
136+
Ok(store)
137+
}
128138
})
129139
}
130140

141+
fn should_wrap_metrics_store(spec: &StoreSpec) -> bool {
142+
matches!(
143+
spec,
144+
StoreSpec::Memory(_)
145+
| StoreSpec::ExperimentalCloudObjectStore(_)
146+
| StoreSpec::ExperimentalMongo(_)
147+
| StoreSpec::Filesystem(_)
148+
| StoreSpec::RedisStore(_)
149+
)
150+
}
151+
131152
fn compute_store_type(spec: &StoreSpec) -> StoreType {
132153
match spec {
133154
StoreSpec::Memory(_) => StoreType::Memory,
134-
StoreSpec::ExperimentalCloudObjectStore(s) => {
135-
match s {
136-
ExperimentalCloudObjectSpec::Aws(_) => StoreType::S3,
137-
ExperimentalCloudObjectSpec::Gcs(_) => StoreType::Gcs,
138-
ExperimentalCloudObjectSpec::Ontap(_) => StoreType::OntapS3,
139-
}
155+
StoreSpec::ExperimentalCloudObjectStore(s) => match s {
156+
ExperimentalCloudObjectSpec::Aws(_) => StoreType::S3,
157+
ExperimentalCloudObjectSpec::Gcs(_) => StoreType::Gcs,
158+
ExperimentalCloudObjectSpec::Ontap(_) => StoreType::OntapS3,
140159
},
141160
StoreSpec::RedisStore(_) => StoreType::Redis,
142161
StoreSpec::Verify(_) => StoreType::Verify,
@@ -151,10 +170,10 @@ fn compute_store_type(spec: &StoreSpec) -> StoreType {
151170
StoreSpec::Grpc(_) => StoreType::Grpc,
152171
StoreSpec::Noop(_) => StoreType::Noop,
153172
StoreSpec::ExperimentalMongo(_) => StoreType::Mongo,
154-
StoreSpec::Shard(_) => StoreType::Metrics,
173+
StoreSpec::RefStore(_) => StoreType::Ref,
174+
StoreSpec::Shard(_) => StoreType::Shard,
155175
_ => {
156176
panic!("Invalid store spec: {:?}", spec);
157177
}
158178
}
159179
}
160-

nativelink-util/src/metrics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,8 @@ pub enum StoreType {
15821582
SizePartitioning,
15831583
CompletenessChecking,
15841584
Verify,
1585+
Ref,
1586+
Shard,
15851587
Metrics,
15861588
}
15871589

@@ -1605,6 +1607,8 @@ impl Display for StoreType {
16051607
StoreType::SizePartitioning => write!(f, "size_partitioning"),
16061608
StoreType::CompletenessChecking => write!(f, "completeness_checking"),
16071609
StoreType::Verify => write!(f, "verify"),
1610+
StoreType::Ref => write!(f, "ref"),
1611+
StoreType::Shard => write!(f, "shard"),
16081612
StoreType::Metrics => write!(f, "metrics"),
16091613
}
16101614
}

0 commit comments

Comments
 (0)