snix_store/pathinfoservice/
mod.rs1mod cache;
2mod from_addr;
3mod grpc;
4mod lru;
5mod memory;
6mod nix_http;
7mod redb;
8mod signing_wrapper;
9
10#[cfg(any(feature = "fuse", feature = "virtiofs"))]
11mod fs;
12
13#[cfg(test)]
14mod tests;
15
16use auto_impl::auto_impl;
17use futures::stream::BoxStream;
18use snix_castore::Error;
19use snix_castore::composition::{Registry, ServiceBuilder};
20use tonic::async_trait;
21
22use crate::nar::NarCalculationService;
23pub use crate::path_info::PathInfo;
24
25pub use self::cache::{Cache as CachePathInfoService, CacheConfig as CachePathInfoServiceConfig};
26pub use self::from_addr::from_addr;
27pub use self::grpc::{GRPCPathInfoService, GRPCPathInfoServiceConfig};
28pub use self::lru::{LruPathInfoService, LruPathInfoServiceConfig};
29pub use self::memory::{MemoryPathInfoService, MemoryPathInfoServiceConfig};
30pub use self::nix_http::{NixHTTPPathInfoService, NixHTTPPathInfoServiceConfig};
31pub use self::redb::{RedbPathInfoService, RedbPathInfoServiceConfig};
32pub use self::signing_wrapper::{KeyFileSigningPathInfoServiceConfig, SigningPathInfoService};
33
34#[cfg(test)]
35pub(crate) use self::signing_wrapper::test_signing_service;
36
37#[cfg(feature = "cloud")]
38mod bigtable;
39#[cfg(feature = "cloud")]
40pub use self::bigtable::{BigtableParameters, BigtablePathInfoService};
41
42#[cfg(any(feature = "fuse", feature = "virtiofs"))]
43pub use self::fs::make_fs;
44
45#[async_trait]
47#[auto_impl(&, &mut, Arc, Box)]
48pub trait PathInfoService: Send + Sync {
49 async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error>;
51
52 async fn put(&self, path_info: PathInfo) -> Result<PathInfo, Error>;
55
56 fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>;
64
65 fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>> {
68 None
69 }
70}
71
72pub(crate) fn register_pathinfo_services(reg: &mut Registry) {
74 reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, CachePathInfoServiceConfig>("cache");
75 reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, GRPCPathInfoServiceConfig>("grpc");
76 reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, LruPathInfoServiceConfig>("lru");
77 reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, MemoryPathInfoServiceConfig>("memory");
78 reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, NixHTTPPathInfoServiceConfig>("nix");
79 reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, RedbPathInfoServiceConfig>("redb");
80 reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, KeyFileSigningPathInfoServiceConfig>("keyfile-signing");
81 #[cfg(feature = "cloud")]
82 {
83 reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, BigtableParameters>(
84 "bigtable",
85 );
86 }
87}