harmos_domain/operations/storage/
follow_production.rs1use super::IO_POLICY;
24use crate::MemorySize;
25use crate::model::storage::codec::{Nested, Unsigned, product};
26use crate::model::storage::files::{FileBatch, FileProgress, StagedFile};
27use crate::operations::{ReplaySafety, Visibility};
28
29product!(FollowProduction {
34 file: Nested<StagedFile> => 1,
35 offset: Unsigned => 2,
36});
37
38crate::declare!(FollowProduction {
39 id: "storage.follow_production",
40 version: 1,
41 policy: IO_POLICY,
42 response: FileProgress,
43 output: FileBatch,
44 visibility: Visibility::Shared,
45 replay: ReplaySafety::Unknown,
46 grpc: ("harmos.storage.v1", "Storage", "FollowProduction"),
47 grant: |request: &FollowProduction| Some(crate::plugin::Grant::of("storage.follow_production", request.file.id.as_str().to_owned())),
48});
49
50#[derive(Clone, Debug, PartialEq, Eq)]
55pub struct FollowProduction {
56 pub file: StagedFile,
57 pub offset: u64,
58}
59
60impl MemorySize for FollowProduction {
67 fn memory_size(&self) -> usize {
68 std::mem::size_of::<Self>()
69 .saturating_add(self.file.memory_size().saturating_sub(std::mem::size_of_val(&self.file)))
70 .saturating_add(self.offset.memory_size().saturating_sub(std::mem::size_of_val(&self.offset)))
71 }
72}
73
74