@@ -42,9 +42,41 @@ use crate::monitor::{
42
42
use crate :: opts:: StorageOpts ;
43
43
use crate :: StateStore ;
44
44
45
- pub type HummockStorageType = impl StateStore + AsHummock ;
46
- pub type MemoryStateStoreType = impl StateStore + AsHummock ;
47
- pub type SledStateStoreType = impl StateStore + AsHummock ;
45
+ mod opaque_type {
46
+ use super :: * ;
47
+
48
+ pub type HummockStorageType = impl StateStore + AsHummock ;
49
+ pub type MemoryStateStoreType = impl StateStore + AsHummock ;
50
+ pub type SledStateStoreType = impl StateStore + AsHummock ;
51
+
52
+ impl StateStoreImpl {
53
+ pub ( super ) fn in_memory (
54
+ state_store : MemoryStateStore ,
55
+ storage_metrics : Arc < MonitoredStorageMetrics > ,
56
+ ) -> Self {
57
+ // The specific type of MemoryStateStoreType in deducted here.
58
+ Self :: MemoryStateStore ( may_dynamic_dispatch ( state_store) . monitored ( storage_metrics) )
59
+ }
60
+
61
+ pub fn hummock (
62
+ state_store : HummockStorage ,
63
+ storage_metrics : Arc < MonitoredStorageMetrics > ,
64
+ ) -> Self {
65
+ // The specific type of HummockStateStoreType in deducted here.
66
+ Self :: HummockStateStore (
67
+ may_dynamic_dispatch ( may_verify ( state_store) ) . monitored ( storage_metrics) ,
68
+ )
69
+ }
70
+
71
+ pub fn sled (
72
+ state_store : SledStateStore ,
73
+ storage_metrics : Arc < MonitoredStorageMetrics > ,
74
+ ) -> Self {
75
+ Self :: SledStateStore ( may_dynamic_dispatch ( state_store) . monitored ( storage_metrics) )
76
+ }
77
+ }
78
+ }
79
+ pub use opaque_type:: { HummockStorageType , MemoryStateStoreType , SledStateStoreType } ;
48
80
49
81
/// The type erased [`StateStore`].
50
82
#[ derive( Clone , EnumAsInner ) ]
@@ -109,31 +141,6 @@ fn may_verify(state_store: impl StateStore + AsHummock) -> impl StateStore + AsH
109
141
}
110
142
111
143
impl StateStoreImpl {
112
- fn in_memory (
113
- state_store : MemoryStateStore ,
114
- storage_metrics : Arc < MonitoredStorageMetrics > ,
115
- ) -> Self {
116
- // The specific type of MemoryStateStoreType in deducted here.
117
- Self :: MemoryStateStore ( may_dynamic_dispatch ( state_store) . monitored ( storage_metrics) )
118
- }
119
-
120
- pub fn hummock (
121
- state_store : HummockStorage ,
122
- storage_metrics : Arc < MonitoredStorageMetrics > ,
123
- ) -> Self {
124
- // The specific type of HummockStateStoreType in deducted here.
125
- Self :: HummockStateStore (
126
- may_dynamic_dispatch ( may_verify ( state_store) ) . monitored ( storage_metrics) ,
127
- )
128
- }
129
-
130
- pub fn sled (
131
- state_store : SledStateStore ,
132
- storage_metrics : Arc < MonitoredStorageMetrics > ,
133
- ) -> Self {
134
- Self :: SledStateStore ( may_dynamic_dispatch ( state_store) . monitored ( storage_metrics) )
135
- }
136
-
137
144
pub fn shared_in_memory_store ( storage_metrics : Arc < MonitoredStorageMetrics > ) -> Self {
138
145
Self :: in_memory ( MemoryStateStore :: shared ( ) , storage_metrics)
139
146
}
0 commit comments