LCOV - code coverage report
Current view: top level - pageserver/src/tenant/remote_timeline_client - manifest.rs (source / functions) Coverage Total Hit
Test: 7179b4db0d82ca8088cc95c44c4be4232078509c.info Lines: 64.3 % 14 9
Test Date: 2024-11-21 16:46:58 Functions: 10.5 % 19 2

            Line data    Source code
       1              : use chrono::NaiveDateTime;
       2              : use serde::{Deserialize, Serialize};
       3              : use utils::{id::TimelineId, lsn::Lsn};
       4              : 
       5              : /// Tenant-shard scoped manifest
       6            0 : #[derive(Clone, Serialize, Deserialize, PartialEq, Eq)]
       7              : pub struct TenantManifest {
       8              :     /// Debugging aid describing the version of this manifest.
       9              :     /// Can also be used for distinguishing breaking changes later on.
      10              :     pub version: usize,
      11              : 
      12              :     /// The list of offloaded timelines together with enough information
      13              :     /// to not have to actually load them.
      14              :     ///
      15              :     /// Note: the timelines mentioned in this list might be deleted, i.e.
      16              :     /// we don't hold an invariant that the references aren't dangling.
      17              :     /// Existence of index-part.json is the actual indicator of timeline existence.
      18              :     pub offloaded_timelines: Vec<OffloadedTimelineManifest>,
      19              : }
      20              : 
      21              : /// The remote level representation of an offloaded timeline.
      22              : ///
      23              : /// Very similar to [`pageserver_api::models::OffloadedTimelineInfo`],
      24              : /// but the two datastructures serve different needs, this is for a persistent disk format
      25              : /// that must be backwards compatible, while the other is only for informative purposes.
      26            0 : #[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq)]
      27              : pub struct OffloadedTimelineManifest {
      28              :     pub timeline_id: TimelineId,
      29              :     /// Whether the timeline has a parent it has been branched off from or not
      30              :     pub ancestor_timeline_id: Option<TimelineId>,
      31              :     /// Whether to retain the branch lsn at the ancestor or not
      32              :     pub ancestor_retain_lsn: Option<Lsn>,
      33              :     /// The time point when the timeline was archived
      34              :     pub archived_at: NaiveDateTime,
      35              : }
      36              : 
      37              : pub const LATEST_TENANT_MANIFEST_VERSION: usize = 1;
      38              : 
      39              : impl TenantManifest {
      40          192 :     pub(crate) fn empty() -> Self {
      41          192 :         Self {
      42          192 :             version: LATEST_TENANT_MANIFEST_VERSION,
      43          192 :             offloaded_timelines: vec![],
      44          192 :         }
      45          192 :     }
      46            0 :     pub(crate) fn from_json_bytes(bytes: &[u8]) -> Result<Self, serde_json::Error> {
      47            0 :         serde_json::from_slice::<Self>(bytes)
      48            0 :     }
      49              : 
      50            2 :     pub(crate) fn to_json_bytes(&self) -> serde_json::Result<Vec<u8>> {
      51            2 :         serde_json::to_vec(self)
      52            2 :     }
      53              : }
        

Generated by: LCOV version 2.1-beta