Skip to main content

mssf_util/mock/
stateless.rs

1// ------------------------------------------------------------
2// Copyright (c) Microsoft Corporation.  All rights reserved.
3// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
4// ------------------------------------------------------------
5
6use std::sync::Arc;
7
8use mssf_core::{runtime::IStatelessServicePartition, types::ServicePartitionInformation};
9
10/// Mock for IStatelessServicePartition
11/// Currently does not react to any reports
12pub struct StatelessServicePartitionMock {
13    info: ServicePartitionInformation,
14}
15
16impl StatelessServicePartitionMock {
17    /// Create a new mock with given partition info
18    pub fn new(info: ServicePartitionInformation) -> Self {
19        Self { info }
20    }
21    pub fn new_arc(info: ServicePartitionInformation) -> Arc<dyn IStatelessServicePartition> {
22        Arc::new(Self::new(info))
23    }
24}
25
26impl IStatelessServicePartition for StatelessServicePartitionMock {
27    fn get_partition_info(&self) -> mssf_core::Result<ServicePartitionInformation> {
28        Ok(self.info.clone())
29    }
30
31    fn report_load(&self, _metrics: &[mssf_core::types::LoadMetric]) -> mssf_core::Result<()> {
32        Ok(())
33    }
34
35    fn report_fault(&self, _fault_type: mssf_core::types::FaultType) -> mssf_core::Result<()> {
36        Ok(())
37    }
38
39    fn report_move_cost(&self, _move_cost: mssf_core::types::MoveCost) -> mssf_core::Result<()> {
40        Ok(())
41    }
42
43    fn report_partition_health(
44        &self,
45        _healthinfo: &mssf_core::types::HealthInformation,
46    ) -> mssf_core::Result<()> {
47        Ok(())
48    }
49
50    fn report_instance_health(
51        &self,
52        _health_info: &mssf_core::types::HealthInformation,
53    ) -> mssf_core::Result<()> {
54        Ok(())
55    }
56}