mssf_core/runtime/
stateless_proxy.rs1use crate::types::{
7 FaultType, HealthInformation, LoadMetric, LoadMetricListRef, MoveCost,
8 ServicePartitionInformation,
9};
10use mssf_com::FabricRuntime::{
11 IFabricStatelessServicePartition, IFabricStatelessServicePartition3,
12};
13use windows_core::Interface;
14#[derive(Debug, Clone)]
16pub struct StatelessServicePartition {
17 com_impl: IFabricStatelessServicePartition3,
18}
19
20impl StatelessServicePartition {
21 pub fn new(com_impl: IFabricStatelessServicePartition) -> StatelessServicePartition {
22 StatelessServicePartition {
23 com_impl: com_impl.cast().unwrap(),
24 } }
26
27 pub fn get_partition_info(&self) -> crate::Result<ServicePartitionInformation> {
28 let raw = unsafe { self.com_impl.GetPartitionInfo() }?;
29 let raw_ref = unsafe { raw.as_ref().unwrap() };
30 assert!(!raw.is_null());
31 Ok(raw_ref.into())
32 }
33
34 pub fn report_load(&self, metrics: &[LoadMetric]) -> crate::Result<()> {
41 let metrics_ref = LoadMetricListRef::from_slice(metrics);
42 let raw = metrics_ref.as_raw_slice();
43 unsafe { self.com_impl.ReportLoad(raw) }.map_err(crate::Error::from)
44 }
45
46 pub fn report_fault(&self, fault_type: FaultType) -> crate::Result<()> {
49 unsafe { self.com_impl.ReportFault(fault_type.into()) }.map_err(crate::Error::from)
50 }
51
52 pub fn report_move_cost(&self, move_cost: MoveCost) -> crate::Result<()> {
59 unsafe { self.com_impl.ReportMoveCost(move_cost.into()) }.map_err(crate::Error::from)
60 }
61
62 pub fn report_partition_health(&self, healthinfo: &HealthInformation) -> crate::Result<()> {
64 let healthinfo_ref = &healthinfo.into();
65 unsafe { self.com_impl.ReportPartitionHealth(healthinfo_ref) }.map_err(crate::Error::from)
66 }
67
68 pub fn report_instance_health(&self, healthinfo: &HealthInformation) -> crate::Result<()> {
70 let healthinfo_ref = &healthinfo.into();
71 unsafe { self.com_impl.ReportInstanceHealth(healthinfo_ref) }.map_err(crate::Error::from)
72 }
73}