mkit_server/pipeline/
shard.rs1mod d34;
6
7use mkit_core::hash::Hash;
8
9pub use d34::D34Shards;
10
11use crate::repo::{NamespaceKey, RepoId};
12use crate::rt::{MaybeSend, MaybeSync};
13use crate::store::{BlobKey, Partition};
14
15pub trait ShardMap: MaybeSend + MaybeSync {
17 fn ref_shard(&self, repo: &RepoId, ref_name: &str) -> Partition;
21
22 fn coordinator(&self, ns: &NamespaceKey) -> Partition;
24
25 fn ref_index(&self, repo: &RepoId, ref_name: &str) -> Partition;
27
28 fn ref_index_partitions(&self, repo: &RepoId) -> Vec<Partition>;
30
31 fn membership(&self, repo: &RepoId, pack: &BlobKey) -> Partition;
33
34 fn object_index(&self, repo: &RepoId, object: &Hash) -> Partition;
36}
37
38#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
41pub struct SinglePartition;
42
43impl ShardMap for SinglePartition {
44 fn ref_shard(&self, repo: &RepoId, _ref_name: &str) -> Partition {
45 Partition::Namespace(repo.namespace.clone())
46 }
47
48 fn coordinator(&self, ns: &NamespaceKey) -> Partition {
49 Partition::Namespace(ns.clone())
50 }
51
52 fn ref_index(&self, repo: &RepoId, _ref_name: &str) -> Partition {
53 Partition::Namespace(repo.namespace.clone())
54 }
55
56 fn ref_index_partitions(&self, repo: &RepoId) -> Vec<Partition> {
57 vec![Partition::Namespace(repo.namespace.clone())]
58 }
59
60 fn membership(&self, repo: &RepoId, _pack: &BlobKey) -> Partition {
61 Partition::Namespace(repo.namespace.clone())
62 }
63
64 fn object_index(&self, repo: &RepoId, _object: &Hash) -> Partition {
65 Partition::Namespace(repo.namespace.clone())
66 }
67}