mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-07 21:42:56 +00:00
We've stored metadata as bytes within the `index_part.json` for long fixed reasons. #7693 added support for reading out normal json serialization of the `TimelineMetadata`. Change the serialization to only write `TimelineMetadata` as json for going forward, keeping the backward compatibility to reading the metadata as bytes. Because of failure to include `alias = "metadata"` in #7693, one more follow-up is required to make the switch from the old name to `"metadata": <json>`, but that affects only the field name in serialized format. In documentation and naming, an effort is made to add enough warning signs around TimelineMetadata so that it will receive no changes in the future. We can add those fields to `IndexPart` directly instead. Additionally, the path to cleaning up `metadata.rs` is documented in the `metadata.rs` module comment. If we must extend `TimelineMetadata` before that, the duplication suggested in [review comment] is the way to go. [review comment]: https://github.com/neondatabase/neon/pull/7699#pullrequestreview-2107081558
21 lines
629 B
Rust
21 lines
629 B
Rust
use anyhow::Context;
|
|
use camino::Utf8PathBuf;
|
|
use pageserver::tenant::IndexPart;
|
|
|
|
#[derive(clap::Subcommand)]
|
|
pub(crate) enum IndexPartCmd {
|
|
Dump { path: Utf8PathBuf },
|
|
}
|
|
|
|
pub(crate) async fn main(cmd: &IndexPartCmd) -> anyhow::Result<()> {
|
|
match cmd {
|
|
IndexPartCmd::Dump { path } => {
|
|
let bytes = tokio::fs::read(path).await.context("read file")?;
|
|
let des: IndexPart = IndexPart::from_s3_bytes(&bytes).context("deserialize")?;
|
|
let output = serde_json::to_string_pretty(&des).context("serialize output")?;
|
|
println!("{output}");
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|