oxedyne/fe2o3/fe2o3_o3db_sync/src/comm/msg.rs
6.3 KiB, 57 runs
created by r1870400018:769, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | use crate::{ |
| 2 | prelude::*, |
| 3 | base::{ |
| 4 | cfg::ZoneConfig, |
| 5 | id::OzoneBotId, |
| 6 | index::{ |
| 7 | WorkerInd, |
| 8 | ZoneInd, |
| 9 | }, |
| 10 | }, |
| 11 | bots::{ |
| 12 | worker::{ |
| 13 | bot_file::GcControl, |
| 14 | bot_reader::ReadResult, |
| 15 | }, |
| 16 | bot_zone::ZoneState, |
| 17 | }, |
| 18 | comm::{ |
| 19 | channels::BotChannels, |
| 20 | response::Responder, |
| 21 | }, |
| 22 | data::{ |
| 23 | cache::{ |
| 24 | Cache, |
| 25 | MetaLocation, |
| 26 | }, |
| 27 | core::{ |
| 28 | Key, |
| 29 | Value, |
| 30 | }, |
| 31 | }, |
| 32 | file::{ |
| 33 | core::FileEntry, |
| 34 | floc::{ |
| 35 | FileLocation, |
| 36 | FileNum, |
| 37 | }, |
| 38 | stored::RecordDigest, |
| 39 | state::{ |
| 40 | FileState, |
| 41 | FileStateMap, |
| 42 | }, |
| 43 | zdir::ZoneDir, |
| 44 | }, |
| 45 | }; |
| 46 | |
| 47 | use oxedyne_fe2o3_bot::msg::BotMsg; |
| 48 | use oxedyne_fe2o3_iop_crypto::enc::Encrypter; |
| 49 | use oxedyne_fe2o3_iop_db::api::{ |
| 50 | Meta, |
| 51 | RestSchemesOverride, |
| 52 | ScanOpts, |
| 53 | }; |
| 54 | use oxedyne_fe2o3_iop_hash::api::Hasher; |
| 55 | use oxedyne_fe2o3_jdat::{ |
| 56 | Dat, |
| 57 | id::NumIdDat, |
| 58 | }; |
| 59 | |
| 60 | use std::{ |
| 61 | collections::BTreeMap, |
| 62 | }; |
| 63 | |
| 64 | #[derive(Clone, Debug)] |
| 65 | pub enum OzoneMsg< |
| 66 | const UIDL: usize, |
| 67 | UID: NumIdDat<UIDL>, |
| 68 | ENC: Encrypter, |
| 69 | KH: Hasher, |
| 70 | > { |
| 71 | None, |
| 72 | // Advise |
| 73 | CacheSize(usize, usize, usize), |
| 74 | SetCacheSizeLimit(usize), |
| 75 | Channels(BotChannels<UIDL, UID, ENC, KH>, Responder<UIDL, UID, ENC, KH>), |
| 76 | ChannelsReceived(OzoneBotId), |
| 77 | Config(OzoneConfig), |
| 78 | //ConfigConfirm(OzoneBotId, Ticket), |
| 79 | Finish, |
| 80 | FileReplaced(FileNum, FileType), // a collection renamed a new file over this one |
| 81 | GcCompleted(FileNum, FileState, usize), |
| 82 | InitTest, |
| 83 | MessageCount(usize), |
| 84 | NewFileStates(FileStateMap), |
| 85 | ReadFinished(FileNum), |
| 86 | ScheduleOld(FileLocation, RecordDigest, OzoneBotId), |
| 87 | ShardFileSize(usize, usize), |
| 88 | UpdateData { |
| 89 | floc_new: FileLocation, |
| 90 | ilen: usize, |
| 91 | floc_old_opt: Option<(FileLocation, RecordDigest)>, // the record superseded |
| 92 | from_id: OzoneBotId, |
| 93 | }, |
| 94 | ZoneDir(ZoneInd, ZoneDir), |
| 95 | ZoneInitTrigger(Responder<UIDL, UID, ENC, KH>), // sup -> cfg, each zone answers when ready |
| 96 | ZoneInit(ZoneDir, ZoneConfig, Responder<UIDL, UID, ENC, KH>), |
| 97 | ZoneState(usize, ZoneState), |
| 98 | // Command |
| 99 | GcControl(GcControl, Responder<UIDL, UID, ENC, KH>), // sup -> gbot, control gc activation |
| 100 | ClearCache(Responder<UIDL, UID, ENC, KH>), |
| 101 | CloseOldLiveFileState { |
| 102 | fnum_old: FileNum, |
| 103 | fnum_new: FileNum, |
| 104 | new_dat_size: u64, |
| 105 | new_ind_size: u64, |
| 106 | resp: Responder<UIDL, UID, ENC, KH>, |
| 107 | }, |
| 108 | OpenNewLiveFileState { |
| 109 | fnum_new: FileNum, |
| 110 | new_dat_size: u64, |
| 111 | new_ind_size: u64, |
| 112 | resp: Responder<UIDL, UID, ENC, KH>, |
| 113 | }, |
| 114 | // Request |
| 115 | CacheDataFile { |
| 116 | fnum: FileNum, |
| 117 | dat_file_size: usize, |
| 118 | resp: Responder<UIDL, UID, ENC, KH>, |
| 119 | }, |
| 120 | CacheIndexFile{ |
| 121 | fnum: FileNum, |
| 122 | dat_file_size: usize, |
| 123 | ind_file_size: usize, |
| 124 | resp: Responder<UIDL, UID, ENC, KH>, |
| 125 | }, |
| 126 | CollectGarbage { |
| 127 | fnum: FileNum, |
| 128 | fstat: FileState, |
| 129 | fbot_index: usize, |
| 130 | }, |
| 131 | //Delete(KeyVal, Responder<UIDL, UID, ENC, KH>), |
| 132 | DumpCacheRequest(Responder<UIDL, UID, ENC, KH>), |
| 133 | DumpFiles(Responder<UIDL, UID, ENC, KH>), |
| 134 | DumpFileStatesRequest(Responder<UIDL, UID, ENC, KH>), |
| 135 | GcCacheUpdateRequest(Vec<(Vec<u8>, FileLocation, Meta<UIDL, UID>)>, Responder<UIDL, UID, ENC, KH>), |
| 136 | //GetUsers(Responder<UIDL, UID, ENC, KH>), |
| 137 | GetZoneDir(Responder<UIDL, UID, ENC, KH>), |
| 138 | Insert( |
| 139 | Vec<u8>, |
| 140 | Option<Vec<u8>>, |
| 141 | Option<usize>, |
| 142 | FileLocation, |
| 143 | usize, // stored index length |
| 144 | Meta<UIDL, UID>, |
| 145 | Responder<UIDL, UID, ENC, KH>, |
| 146 | Option<Error<ErrTag>>, // written, but its barrier failed: the caller's answer |
| 147 | ), |
| 148 | NewLiveFile(Option<FileNum>, Responder<UIDL, UID, ENC, KH>), // Explicit file number for init, None for routine new file. |
| 149 | NextLiveFile(Responder<UIDL, UID, ENC, KH>), // A routine request by a wbot to the zbot for the next live file. |
| 150 | OzoneStateRequest(Responder<UIDL, UID, ENC, KH>), |
| 151 | Ping(OzoneBotId, Responder<UIDL, UID, ENC, KH>), |
| 152 | Pong(OzoneBotId, usize), |
| 153 | Read(Key, usize, Responder<UIDL, UID, ENC, KH>), |
| 154 | Ready, |
| 155 | ReadCache(Key, Responder<UIDL, UID, ENC, KH>), |
| 156 | ReadFileRequest(FileNum, Vec<u8>, MetaLocation<UIDL, UID>, Responder<UIDL, UID, ENC, KH>), // key bytes |
| 157 | ScanRequest { |
| 158 | opts: ScanOpts, |
| 159 | schms2: Option<RestSchemesOverride<ENC, KH>>, |
| 160 | resp: Responder<UIDL, UID, ENC, KH>, |
| 161 | }, |
| 162 | Shutdown(OzoneBotId, Responder<UIDL, UID, ENC, KH>), |
| 163 | Write { |
| 164 | kstored: Vec<u8>, |
| 165 | vstored: Vec<u8>, |
| 166 | klen_cache: usize, |
| 167 | cind: Option<usize>, |
| 168 | meta: Meta<UIDL, UID>, |
| 169 | cbpind: usize, |
| 170 | resp: Responder<UIDL, UID, ENC, KH>, |
| 171 | }, |
| 172 | // Respond |
| 173 | Chunks(usize), // Number of chunks. |
| 174 | DumpCacheResponse(WorkerInd, Cache<UIDL, UID>), |
| 175 | DumpFileStatesResponse(WorkerInd, FileStateMap), |
| 176 | Error(Error<ErrTag>), |
| 177 | Files(ZoneInd, BTreeMap<String, FileEntry>), |
| 178 | GcCacheUpdateResponse(Vec<(FileLocation, RecordDigest)>), // re-anchored, from where |
| 179 | KeyExists(bool), |
| 180 | KeyChunkExists(bool, usize), // includes chunk index |
| 181 | Ok, |
| 182 | //OkFrom(OzoneBotId), |
| 183 | OzoneStateResponse(Vec<ZoneState>), |
| 184 | ScanEntries(Vec<(Dat, Dat, Meta<UIDL, UID>)>), |
| 185 | //UserKeys(Vec<(u128, Dat)>), |
| 186 | UseLiveFile(FileNum), |
| 187 | Value(Value<UIDL, UID>), |
| 188 | Written, // a write's record is appended; its durable answer follows |
| 189 | ReadResult(ReadResult<UIDL, UID>), |
| 190 | // Wrap |
| 191 | ProcessGcBuffer(Box<OzoneMsg<UIDL, UID, ENC, KH>>), |
| 192 | // Server |
| 193 | Get { |
| 194 | key: Dat, |
| 195 | schms2: Option<RestSchemesOverride<ENC, KH>>, |
| 196 | resp: Responder<UIDL, UID, ENC, KH>, |
| 197 | }, |
| 198 | GetResult(Option<(Dat, Meta<UIDL, UID>)>), |
| 199 | Put { |
| 200 | key: Dat, |
| 201 | val: Dat, |
| 202 | user: UID, |
| 203 | schms2: Option<RestSchemesOverride<ENC, KH>>, |
| 204 | resp: Responder<UIDL, UID, ENC, KH>, |
| 205 | }, |
| 206 | } |
| 207 | |
| 208 | impl< |
| 209 | const UIDL: usize, |
| 210 | UID: NumIdDat<UIDL>, |
| 211 | ENC: Encrypter, |
| 212 | KH: Hasher, |
| 213 | > |
| 214 | BotMsg<ErrTag> for OzoneMsg<UIDL, UID, ENC, KH> {} |