rocketmq-store-api 1.0.0

Runtime-neutral RocketMQ storage capability contracts
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
// Copyright 2023 The RocketMQ Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![deny(missing_docs)]

//! Storage capabilities and their contract-violation model.

mod capability;
pub mod checkpoint;
mod checkpoint_artifact;
mod contract;
mod error;
mod ha_contract;
mod progress;
mod timer;
mod timer_snapshot;
mod wal;

pub use capability::AdminStore;
pub use capability::DerivedRecordSink;
pub use capability::MessageAppender;
pub use capability::MessageReader;
pub use capability::OffsetIndex;
pub use capability::ReleaseCheckpointCreateOutcome;
pub use capability::ReleaseCheckpointCreateRejection;
pub use capability::ReleaseCheckpointRestoreOutcome;
pub use capability::ReleaseCheckpointRestoreRejection;
pub use capability::ReleaseCheckpointStore;
pub use capability::ReplicationControl;
pub use capability::StoreHealth;
pub use capability::StoreLifecycle;
pub use checkpoint::CheckpointArtifact;
pub use checkpoint::CheckpointBackend;
pub use checkpoint::CheckpointManifest;
pub use checkpoint::CheckpointOffsets;
pub use checkpoint::CheckpointRequest;
pub use checkpoint::CheckpointRestoreVerification;
pub use checkpoint::CheckpointStorageIdentity;
pub use checkpoint::CHECKPOINT_SCHEMA_VERSION;
pub use checkpoint_artifact::file_uri_to_path;
pub use checkpoint_artifact::hash_checkpoint_directory;
pub use checkpoint_artifact::path_to_file_uri;
pub use checkpoint_artifact::CheckpointDirectoryDigest;
pub use checkpoint_artifact::RELEASE_CHECKPOINT_MANIFEST_FILE;
pub use contract::StoreContractViolation;
pub use error::StoreComponent;
pub use error::StoreError;
pub use error::StoreOperation;
pub use ha_contract::decide_replication;
pub use ha_contract::AckPolicy;
pub use ha_contract::HaRejectReason;
pub use ha_contract::MasterEpoch;
pub use ha_contract::ReplicaAck;
pub use ha_contract::ReplicaCount;
pub use ha_contract::ReplicationAcknowledgement;
pub use ha_contract::ReplicationDecision;
pub use ha_contract::ReplicationObservation;
pub use ha_contract::SyncStateSet;
pub use ha_contract::SyncStateSetEpoch;
pub use ha_contract::WriteAuthority;
pub use ha_contract::WriteLeaseToken;
pub use progress::CursorAdvance;
pub use progress::CursorAdvanceDisposition;
pub use progress::DerivedCheckpoint;
pub use progress::DerivedCursor;
pub use progress::DerivedEngine;
pub use progress::DerivedRecordId;
pub use progress::LegacyDerivedCursorV0;
pub use progress::DERIVED_CHECKPOINT_ENCODED_LEN;
pub use progress::DERIVED_CHECKPOINT_FORMAT_VERSION;
pub use timer::PersistedTimerRoute;
pub use timer::TimerEngineEpoch;
pub use timer::TimerEngineId;
pub use timer::TimerGeneration;
pub use timer::TimerId;
pub use timer::TimerPayloadLocator;
pub use timer::TimerPayloadStoreLocator;
pub use timer::TimerRecallRequest;
pub use timer::TimerRecallStatus;
pub use timer::TimerSourceCqOffset;
pub use timer::TimerStoreMode;
pub use timer::TimerTimelineCursor;
pub use timer::EXTENDED_TIMELINE_FORMAT_VERSION;
pub use timer::JAVA_COMPAT_TIMER_FORMAT_VERSION;
pub use timer_snapshot::TimerSnapshotFile;
pub use timer_snapshot::TimerSnapshotManifest;
pub use timer_snapshot::TimerTimelineIndexKind;
pub use timer_snapshot::TIMER_SNAPSHOT_SCHEMA_VERSION;
pub use wal::WalPort;

use std::fmt;
use std::ops::Range;

use bytes::Bytes;

/// Durability reached by a primary-log append.
///
/// Derived-record progress never upgrades this value.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Durability {
    /// The primary log accepted the bytes, without a durable-write guarantee.
    #[default]
    Memory,
    /// The durable watermark covers the complete appended range locally.
    Local,
    /// The configured replica acknowledgement condition was also satisfied.
    Replicated,
}

/// Backend-neutral outcome of a legacy-compatible append attempt.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum AppendStatus {
    #[default]
    /// Represents the put ok case.
    PutOk,
    /// Represents the flush disk timeout case.
    FlushDiskTimeout,
    /// Represents the flush replica timeout case.
    FlushReplicaTimeout,
    /// Represents the replica unavailable case.
    ReplicaUnavailable,
    /// Represents the service unavailable case.
    ServiceUnavailable,
    /// Represents the storage unavailable case.
    StorageUnavailable,
    /// Represents the invalid message case.
    InvalidMessage,
    /// Represents the properties too large case.
    PropertiesTooLarge,
    /// Represents the page cache busy case.
    PageCacheBusy,
    /// Represents the unknown case.
    Unknown,
    /// Represents the insufficient replicas case.
    InsufficientReplicas,
    /// Represents the remote append failed case.
    RemoteAppendFailed,
    /// Represents the queue limit exceeded case.
    QueueLimitExceeded,
    /// Represents the schedule flow control case.
    ScheduleFlowControl,
    /// Represents the schedule message illegal case.
    ScheduleMessageIllegal,
    /// Represents the schedule disabled case.
    ScheduleDisabled,
}

impl AppendStatus {
    /// Returns whether the primary log accepted the append.
    pub const fn is_accepted(self) -> bool {
        matches!(
            self,
            Self::PutOk | Self::FlushDiskTimeout | Self::FlushReplicaTimeout | Self::ReplicaUnavailable
        )
    }
}

/// Canonical receipt for one primary-log append attempt.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct AppendReceipt {
    status: AppendStatus,
    appended_range: Option<Range<i64>>,
    appended_watermark: i64,
    durable_watermark: i64,
    durability: Durability,
}

impl AppendReceipt {
    /// Creates a receipt after validating range, status, watermark, and durability invariants.
    ///
    /// # Errors
    ///
    /// Returns [`StoreContractViolation`] when any receipt field contradicts another field.
    pub fn try_new(
        status: AppendStatus,
        appended_range: Range<i64>,
        appended_watermark: i64,
        durable_watermark: i64,
        durability: Durability,
    ) -> Result<Self, StoreContractViolation> {
        if appended_range.start == appended_range.end {
            return Err(StoreContractViolation::AppendReceiptEmptyRange);
        }
        if appended_range.start > appended_range.end {
            return Err(StoreContractViolation::AppendReceiptReversedRange);
        }
        if !status.is_accepted() {
            return Err(StoreContractViolation::AppendReceiptRejectedStatusWithRange);
        }
        if appended_watermark < appended_range.end {
            return Err(StoreContractViolation::AppendReceiptAppendedWatermarkBehindRange);
        }
        if durable_watermark > appended_watermark {
            return Err(StoreContractViolation::AppendReceiptDurableWatermarkAheadOfAppended);
        }
        if durability == Durability::Replicated {
            return Err(StoreContractViolation::AppendReceiptReplicatedDurabilityRequiresDecision);
        }
        match durability {
            Durability::Memory if durable_watermark >= appended_range.end => {
                return Err(StoreContractViolation::AppendReceiptMemoryDurabilityAlreadyCovered);
            }
            Durability::Local | Durability::Replicated if durable_watermark < appended_range.end => {
                return Err(StoreContractViolation::AppendReceiptDurableWatermarkBehindRange);
            }
            Durability::Memory | Durability::Local | Durability::Replicated => {}
        }
        Ok(Self {
            status,
            appended_range: Some(appended_range),
            appended_watermark,
            durable_watermark,
            durability,
        })
    }

    /// Creates a receipt from a proof produced by [`decide_replication`].
    ///
    /// # Errors
    ///
    /// Returns [`StoreContractViolation`] when receipt fields contradict each other or the supplied
    /// acknowledgement does not cover the complete appended range.
    pub fn try_new_with_replication(
        status: AppendStatus,
        appended_range: Range<i64>,
        appended_watermark: i64,
        durable_watermark: i64,
        acknowledgement: ReplicationAcknowledgement,
    ) -> Result<Self, StoreContractViolation> {
        if acknowledgement.acknowledged_offset() < appended_range.end {
            return Err(StoreContractViolation::AppendReceiptReplicationDecisionBehindRange);
        }
        let mut receipt = Self::try_new(
            status,
            appended_range,
            appended_watermark,
            durable_watermark,
            Durability::Local,
        )?;
        receipt.durability = acknowledgement.durability();
        Ok(receipt)
    }

    /// Creates a rejected receipt after validating status and watermark invariants.
    ///
    /// # Errors
    ///
    /// Returns [`StoreContractViolation`] for an accepted status or reversed progress watermarks.
    pub const fn try_rejected(
        status: AppendStatus,
        appended_watermark: i64,
        durable_watermark: i64,
    ) -> Result<Self, StoreContractViolation> {
        if status.is_accepted() {
            return Err(StoreContractViolation::AppendReceiptAcceptedStatusWithoutRange);
        }
        if durable_watermark > appended_watermark {
            return Err(StoreContractViolation::AppendReceiptDurableWatermarkAheadOfAppended);
        }
        Ok(Self {
            status,
            appended_range: None,
            appended_watermark,
            durable_watermark,
            durability: Durability::Memory,
        })
    }

    /// Returns the neutral append outcome.
    pub const fn status(&self) -> AppendStatus {
        self.status
    }

    /// Returns the half-open physical range written by this operation.
    pub fn appended_range(&self) -> Option<Range<i64>> {
        self.appended_range.clone()
    }

    /// Returns the first physical byte appended by this operation.
    pub fn first_appended_offset(&self) -> Option<i64> {
        self.appended_range.as_ref().map(|range| range.start)
    }

    /// Returns the last physical byte appended by this operation.
    pub fn last_appended_offset(&self) -> Option<i64> {
        self.appended_range.as_ref().map(|range| range.end - 1)
    }

    /// Returns the exclusive primary-log append watermark observed after the operation.
    pub const fn appended_watermark(&self) -> i64 {
        self.appended_watermark
    }

    /// Returns the exclusive durable watermark observed after the operation.
    pub const fn durable_watermark(&self) -> i64 {
        self.durable_watermark
    }

    /// Returns the explicitly reached durability level.
    pub const fn durability(&self) -> Durability {
        self.durability
    }

    /// Returns whether the primary log accepted a non-empty appended range.
    pub fn is_accepted(&self) -> bool {
        self.status.is_accepted() && self.appended_range.is_some()
    }

    /// Returns whether the complete appended range reached the reported durable watermark.
    pub fn is_durable(&self) -> bool {
        self.is_accepted()
            && self.durability != Durability::Memory
            && self
                .appended_range
                .as_ref()
                .is_some_and(|range| self.durable_watermark >= range.end)
    }
}

/// Progress of derived records, independent from primary-log acknowledgement.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct DerivedProgress {
    source_watermark: i64,
    derived_watermark: i64,
}

impl DerivedProgress {
    /// Creates an independent derived-progress observation.
    pub const fn new(source_watermark: i64, derived_watermark: i64) -> Self {
        Self {
            source_watermark,
            derived_watermark,
        }
    }

    /// Returns the exclusive primary-log source watermark observed by derivation.
    pub const fn source_watermark(self) -> i64 {
        self.source_watermark
    }

    /// Returns the exclusive watermark completed by the derived store.
    pub const fn derived_watermark(self) -> i64 {
        self.derived_watermark
    }

    /// Derived progress is never a primary append acknowledgement.
    pub const fn acknowledges_primary_append(self) -> bool {
        false
    }

    /// Derived progress is never a primary durability condition.
    pub const fn satisfies_primary_durability(self) -> bool {
        false
    }
}

/// Bytes whose backend lease remains held for the lifetime of this value.
pub struct LeasedBytes<L> {
    // Bytes drop before the lease, so a backend view is gone before its guard is released.
    bytes: Bytes,
    lease: L,
}

impl<L> LeasedBytes<L> {
    /// Couples bytes with the guard that keeps their source alive.
    pub const fn new(bytes: Bytes, lease: L) -> Self {
        Self { bytes, lease }
    }

    /// Returns the readable bytes while retaining the lease.
    pub const fn bytes(&self) -> &Bytes {
        &self.bytes
    }

    /// Consumes the lease and returns independently owned bytes.
    pub fn into_bytes(self) -> Bytes {
        self.bytes
    }
}

impl<L: fmt::Debug> fmt::Debug for LeasedBytes<L> {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter
            .debug_struct("LeasedBytes")
            .field("bytes", &self.bytes)
            .field("lease", &self.lease)
            .finish()
    }
}

/// Neutral cache-residency observation for a selected byte range.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ReadCacheState {
    #[default]
    /// Represents the unknown case.
    Unknown,
    /// Represents the hot case.
    Hot,
    /// Represents the cold case.
    Cold,
}

/// One selected physical byte range coupled to its backend lease.
#[derive(Debug)]
pub struct SelectResult<L> {
    start_offset: u64,
    data: LeasedBytes<L>,
    cache_state: ReadCacheState,
}

impl<L> SelectResult<L> {
    /// Creates a selected range from neutral bytes and location metadata.
    pub const fn new(start_offset: u64, data: LeasedBytes<L>, cache_state: ReadCacheState) -> Self {
        Self {
            start_offset,
            data,
            cache_state,
        }
    }

    /// Returns the physical start offset.
    pub const fn start_offset(&self) -> u64 {
        self.start_offset
    }

    /// Returns the selected byte length.
    pub fn size(&self) -> usize {
        self.data.bytes().len()
    }

    /// Returns the leased data.
    pub const fn data(&self) -> &LeasedBytes<L> {
        &self.data
    }

    /// Consumes the selected result and returns its leased data.
    pub fn into_data(self) -> LeasedBytes<L> {
        self.data
    }

    /// Returns the neutral cache observation.
    pub const fn cache_state(&self) -> ReadCacheState {
        self.cache_state
    }
}

/// Canonical result status for a bounded logical get.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum GetStatus {
    #[default]
    /// Represents the found case.
    Found,
    /// Represents the no matched message case.
    NoMatchedMessage,
    /// Represents the message was removing case.
    MessageWasRemoving,
    /// Represents the offset found null case.
    OffsetFoundNull,
    /// Represents the offset overflow badly case.
    OffsetOverflowBadly,
    /// Represents the offset overflow one case.
    OffsetOverflowOne,
    /// Represents the offset too small case.
    OffsetTooSmall,
    /// Represents the no matched logic queue case.
    NoMatchedLogicQueue,
    /// Represents the no message in queue case.
    NoMessageInQueue,
    /// Represents the offset reset case.
    OffsetReset,
}

/// Canonical neutral projection of a legacy logical get result.
#[derive(Debug)]
pub struct GetResult<L> {
    /// The records value.
    pub records: Vec<SelectResult<L>>,
    /// The queue offsets value.
    pub queue_offsets: Vec<u64>,
    /// The status value.
    pub status: Option<GetStatus>,
    /// The next begin offset value.
    pub next_begin_offset: i64,
    /// The min offset value.
    pub min_offset: i64,
    /// The max offset value.
    pub max_offset: i64,
    /// The buffer total size value.
    pub buffer_total_size: i32,
    /// The number of message entries.
    pub message_count: i32,
    /// Whether suggest pulling from replica.
    pub suggest_pulling_from_replica: bool,
    /// The number of commercial message entries.
    pub commercial_message_count: i32,
    /// The commercial size per message value.
    pub commercial_size_per_message: i32,
    /// The cold data sum value.
    pub cold_data_sum: i64,
}

impl<L> Default for GetResult<L> {
    fn default() -> Self {
        Self {
            records: Vec::new(),
            queue_offsets: Vec::new(),
            status: None,
            next_begin_offset: 0,
            min_offset: 0,
            max_offset: 0,
            buffer_total_size: 0,
            message_count: 0,
            suggest_pulling_from_replica: false,
            commercial_message_count: 0,
            commercial_size_per_message: 4 * 1024,
            cold_data_sum: 0,
        }
    }
}

/// Owned logical-read outcome after backend leases have been decoded by an adapter.
///
/// This projection keeps storage navigation semantics in the storage boundary while allowing the
/// caller to own decoded records. `None` records remain distinct from a successful read containing
/// an empty record collection.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ReadOutcome<T> {
    status: GetStatus,
    next_begin_offset: i64,
    min_offset: i64,
    max_offset: i64,
    records: Option<Vec<T>>,
}

impl<T> ReadOutcome<T> {
    /// Creates an owned read outcome from canonical store navigation fields.
    pub fn new<R>(status: GetStatus, next_begin_offset: i64, min_offset: i64, max_offset: i64, records: R) -> Self
    where
        R: Into<Option<Vec<T>>>,
    {
        Self {
            status,
            next_begin_offset,
            min_offset,
            max_offset,
            records: records.into(),
        }
    }

    /// Returns the exact backend-neutral logical-read status.
    pub const fn status(&self) -> GetStatus {
        self.status
    }

    /// Returns the next logical offset suggested by the store.
    pub const fn next_begin_offset(&self) -> i64 {
        self.next_begin_offset
    }

    /// Returns the minimum readable logical offset.
    pub const fn min_offset(&self) -> i64 {
        self.min_offset
    }

    /// Returns the maximum logical offset observed by the store.
    pub const fn max_offset(&self) -> i64 {
        self.max_offset
    }

    /// Returns decoded records without transferring ownership.
    pub fn records(&self) -> Option<&[T]> {
        self.records.as_deref()
    }

    /// Consumes the outcome and returns its decoded records.
    pub fn into_records(self) -> Option<Vec<T>> {
        self.records
    }
}

/// Canonical neutral projection of a legacy key query result.
#[derive(Debug)]
pub struct QueryResult<L> {
    /// The records value.
    pub records: Vec<SelectResult<L>>,
    /// The index last update timestamp value.
    pub index_last_update_timestamp: i64,
    /// The index last update physical offset value.
    pub index_last_update_physical_offset: i64,
    /// The buffer total size value.
    pub buffer_total_size: i32,
    /// Whether index query safe.
    pub index_query_safe: bool,
    /// The index safe physical offset value.
    pub index_safe_physical_offset: i64,
    /// The index confirm physical offset value.
    pub index_confirm_physical_offset: i64,
}

impl<L> Default for QueryResult<L> {
    fn default() -> Self {
        Self {
            records: Vec::new(),
            index_last_update_timestamp: 0,
            index_last_update_physical_offset: 0,
            buffer_total_size: 0,
            index_query_safe: true,
            index_safe_physical_offset: 0,
            index_confirm_physical_offset: 0,
        }
    }
}

/// Compact durable-write pressure projection.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct FlushBacklog {
    /// The queue depth value.
    pub queue_depth: u64,
    /// The oldest wait duration in milliseconds.
    pub oldest_wait_millis: u64,
}

/// Canonical backend-neutral health projection.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct StoreHealthSnapshot {
    /// Whether writable.
    pub writable: bool,
    /// Catalog identity of the latest health failure.
    pub last_error: Option<&'static rocketmq_error::ErrorDescriptor>,
    /// Whether page cache busy.
    pub page_cache_busy: bool,
    /// Whether transient pool deficient.
    pub transient_pool_deficient: bool,
    /// The flush backlog value.
    pub flush_backlog: FlushBacklog,
    /// The dispatch behind size in bytes.
    pub dispatch_behind_bytes: i64,
    /// Whether shutdown.
    pub shutdown: bool,
    /// The number of replication pending entries.
    pub replication_pending_count: u64,
    /// The replication oldest wait duration in milliseconds.
    pub replication_oldest_wait_millis: u64,
    /// The appended watermark value.
    pub appended_watermark: i64,
    /// The durable watermark value.
    pub durable_watermark: i64,
}

impl Default for StoreHealthSnapshot {
    fn default() -> Self {
        Self {
            writable: true,
            last_error: None,
            page_cache_busy: false,
            transient_pool_deficient: false,
            flush_backlog: FlushBacklog::default(),
            dispatch_behind_bytes: 0,
            shutdown: false,
            replication_pending_count: 0,
            replication_oldest_wait_millis: 0,
            appended_watermark: 0,
            durable_watermark: 0,
        }
    }
}

impl StoreHealthSnapshot {
    /// Returns whether the store currently accepts primary writes.
    pub const fn writable(&self) -> bool {
        self.writable
    }

    /// Returns the catalog identity of the latest health failure.
    pub const fn last_error(&self) -> Option<&'static rocketmq_error::ErrorDescriptor> {
        self.last_error
    }

    /// Returns the exclusive primary-log append watermark.
    pub const fn appended_watermark(&self) -> i64 {
        self.appended_watermark
    }

    /// Returns the exclusive durable watermark.
    pub const fn durable_watermark(&self) -> i64 {
        self.durable_watermark
    }
}