Downgrade some WARN logs to INFO, update docs for public methods

This commit is contained in:
asonix 2023-09-30 17:52:58 -05:00
parent 01cbe34ac3
commit 47751f3875
3 changed files with 18 additions and 15 deletions

View File

@ -1961,6 +1961,10 @@ impl PictRsConfiguration {
Ok(self) Ok(self)
} }
/// Install the configured pict-rs metrics collector
///
/// This is a no-op if pict-rs is not configured to export metrics. Applications that register
/// their own metrics collectors shouldn't call this method.
pub fn install_metrics(self) -> color_eyre::Result<Self> { pub fn install_metrics(self) -> color_eyre::Result<Self> {
if let Some(addr) = self.config.metrics.prometheus_address { if let Some(addr) = self.config.metrics.prometheus_address {
PrometheusBuilder::new() PrometheusBuilder::new()
@ -1972,9 +1976,6 @@ impl PictRsConfiguration {
} }
/// Run the pict-rs application /// Run the pict-rs application
///
/// This must be called after `init_config`, or else the default configuration builder will run and
/// fail.
pub async fn run(self) -> color_eyre::Result<()> { pub async fn run(self) -> color_eyre::Result<()> {
let PictRsConfiguration { config, operation } = self; let PictRsConfiguration { config, operation } = self;

View File

@ -98,7 +98,9 @@ where
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match self.as_mut().project() { match self.as_mut().project() {
InternalFutureProj::Internal { future } => future.poll(cx), InternalFutureProj::Internal { future } => future.poll(cx),
InternalFutureProj::Error { error } => Poll::Ready(Err(error.take().unwrap().into())), InternalFutureProj::Error { error } => {
Poll::Ready(Err(error.take().expect("Polled after completion").into()))
}
} }
} }
} }

View File

@ -20,7 +20,7 @@ const GENERATOR_KEY: &str = "last-path";
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result<(), Error> { pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result<(), Error> {
tracing::warn!("Running checks"); tracing::info!("Running checks");
if let Err(e) = old_repo.health_check().await { if let Err(e) = old_repo.health_check().await {
tracing::warn!("Old repo is not configured correctly"); tracing::warn!("Old repo is not configured correctly");
return Err(e.into()); return Err(e.into());
@ -32,8 +32,8 @@ pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result
let total_size = old_repo.size().await?; let total_size = old_repo.size().await?;
let pct = (total_size / 100).max(1); let pct = (total_size / 100).max(1);
tracing::warn!("Checks complete, migrating repo"); tracing::info!("Checks complete, migrating repo");
tracing::warn!("{total_size} hashes will be migrated"); tracing::info!("{total_size} hashes will be migrated");
let hash_stream = std::pin::pin!(old_repo.hashes()); let hash_stream = std::pin::pin!(old_repo.hashes());
let mut hash_stream = hash_stream.into_streamer(); let mut hash_stream = hash_stream.into_streamer();
@ -51,7 +51,7 @@ pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result
if index % pct == 0 { if index % pct == 0 {
let percent = index / pct; let percent = index / pct;
tracing::warn!("Migration {percent}% complete - {index}/{total_size}"); tracing::info!("Migration {percent}% complete - {index}/{total_size}");
} }
} }
@ -61,7 +61,7 @@ pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result
.await?; .await?;
} }
tracing::warn!("Migration complete"); tracing::info!("Migration complete");
Ok(()) Ok(())
} }
@ -73,7 +73,7 @@ pub(crate) async fn migrate_04<S: Store + 'static>(
store: S, store: S,
config: Configuration, config: Configuration,
) -> Result<(), Error> { ) -> Result<(), Error> {
tracing::warn!("Running checks"); tracing::info!("Running checks");
if let Err(e) = old_repo.health_check().await { if let Err(e) = old_repo.health_check().await {
tracing::warn!("Old repo is not configured correctly"); tracing::warn!("Old repo is not configured correctly");
return Err(e.into()); return Err(e.into());
@ -89,8 +89,8 @@ pub(crate) async fn migrate_04<S: Store + 'static>(
let total_size = old_repo.size().await?; let total_size = old_repo.size().await?;
let pct = (total_size / 100).max(1); let pct = (total_size / 100).max(1);
tracing::warn!("Checks complete, migrating repo"); tracing::info!("Checks complete, migrating repo");
tracing::warn!("{total_size} hashes will be migrated"); tracing::info!("{total_size} hashes will be migrated");
let mut hash_stream = old_repo.hashes().await.into_streamer(); let mut hash_stream = old_repo.hashes().await.into_streamer();
@ -117,7 +117,7 @@ pub(crate) async fn migrate_04<S: Store + 'static>(
if index % pct == 0 { if index % pct == 0 {
let percent = index / pct; let percent = index / pct;
tracing::warn!("Migration {percent}% complete - {index}/{total_size}"); tracing::info!("Migration {percent}% complete - {index}/{total_size}");
} }
} }
} }
@ -129,7 +129,7 @@ pub(crate) async fn migrate_04<S: Store + 'static>(
if index % pct == 0 { if index % pct == 0 {
let percent = index / pct; let percent = index / pct;
tracing::warn!("Migration {percent}% complete - {index}/{total_size}"); tracing::info!("Migration {percent}% complete - {index}/{total_size}");
} }
} }
@ -145,7 +145,7 @@ pub(crate) async fn migrate_04<S: Store + 'static>(
.await?; .await?;
} }
tracing::warn!("Migration complete"); tracing::info!("Migration complete");
Ok(()) Ok(())
} }