Sends a command to this storage instance.
(&mut self, command: StorageCommand)
| 324 | |
| 325 | /// Sends a command to this storage instance. |
| 326 | pub fn send(&mut self, command: StorageCommand) { |
| 327 | // Record the command so that new replicas can be brought up to speed. |
| 328 | self.history.push(command.clone()); |
| 329 | |
| 330 | match command.clone() { |
| 331 | StorageCommand::RunIngestion(ingestion) => { |
| 332 | // First absorb into our state, because this might change |
| 333 | // scheduling decisions, which need to be respected just below |
| 334 | // when sending commands. |
| 335 | self.absorb_ingestion(*ingestion.clone()); |
| 336 | |
| 337 | for replica in self.active_replicas(&ingestion.id) { |
| 338 | replica.send(StorageCommand::RunIngestion(ingestion.clone())); |
| 339 | } |
| 340 | } |
| 341 | StorageCommand::RunSink(sink) => { |
| 342 | // First absorb into our state, because this might change |
| 343 | // scheduling decisions, which need to be respected just below |
| 344 | // when sending commands. |
| 345 | self.absorb_export(*sink.clone()); |
| 346 | |
| 347 | for replica in self.active_replicas(&sink.id) { |
| 348 | replica.send(StorageCommand::RunSink(sink.clone())); |
| 349 | } |
| 350 | } |
| 351 | StorageCommand::AllowCompaction(id, frontier) => { |
| 352 | // First send out commands and then absorb into our state since |
| 353 | // absorbing them might remove entries from active_ingestions. |
| 354 | for replica in self.active_replicas(&id) { |
| 355 | replica.send(StorageCommand::AllowCompaction( |
| 356 | id.clone(), |
| 357 | frontier.clone(), |
| 358 | )); |
| 359 | } |
| 360 | |
| 361 | self.absorb_compaction(id, frontier); |
| 362 | } |
| 363 | command => { |
| 364 | for replica in self.replicas.values_mut() { |
| 365 | replica.send(command.clone()); |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | if command.installs_objects() && self.replicas.is_empty() { |
| 371 | self.update_paused_statuses(); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | /// Updates internal state based on incoming ingestion commands. |
| 376 | /// |