Skip to main content

mssf_util/monitoring/
entities.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 mssf_core::types::{
7    ApplicationHealth, ApplicationQueryResultItem, ClusterHealth, NodeHealthResult,
8    NodeQueryResultItem, PartitionHealthResult, ReplicaHealthResult, ServiceHealthResult,
9    ServicePartitionQueryResultItem, ServiceQueryResultItem, ServiceReplicaQueryResultItem, Uri,
10};
11
12/// Events produced by HealthDataProducer.
13///
14/// Most variants carry a health entity; `IterationComplete` is a control
15/// marker signalling that a producer loop finished an iteration.
16#[derive(Debug, Clone)]
17pub enum ProducerEvent {
18    Node(NodeHealthEntity),
19    Cluster(ClusterHealthEntity),
20    Application(ApplicationHealthEntity),
21    Partition(PartitionHealthEntity),
22    Service(ServiceHealthEntity),
23    Replica(ReplicaHealthEntity),
24    /// Marker emitted at the end of a producer loop iteration. Allows a
25    /// consumer to detect that a loop has produced a full set of data for the
26    /// current iteration.
27    IterationComplete(LoopKind),
28}
29
30/// Identifies which producer loop an [`ProducerEvent::IterationComplete`] marker
31/// belongs to.
32#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33pub enum LoopKind {
34    /// The cluster and node health loop.
35    ClusterNode,
36    /// The application (and services, partitions, replicas) health loop.
37    Application,
38}
39
40/// There is no info for cluster name in FabricClient.
41/// User is supposed to inject the cluster name in consumer side.
42#[derive(Debug, Clone)]
43pub struct ClusterHealthEntity {
44    pub health: ClusterHealth,
45}
46
47#[derive(Debug, Clone)]
48pub struct NodeHealthEntity {
49    pub node: NodeQueryResultItem,
50    pub health: NodeHealthResult,
51}
52
53#[derive(Debug, Clone)]
54pub struct ApplicationHealthEntity {
55    pub application: ApplicationQueryResultItem,
56    pub health: ApplicationHealth,
57}
58
59#[derive(Debug, Clone)]
60pub struct ServiceHealthEntity {
61    pub service: ServiceQueryResultItem,
62    pub health: ServiceHealthResult,
63}
64
65#[derive(Debug, Clone)]
66pub struct PartitionHealthEntity {
67    pub partition: ServicePartitionQueryResultItem,
68    pub health: PartitionHealthResult,
69    pub service_name: Uri,
70    pub application_name: Uri,
71}
72
73#[derive(Debug, Clone)]
74pub struct ReplicaHealthEntity {
75    pub replica: ServiceReplicaQueryResultItem,
76    pub health: ReplicaHealthResult,
77    pub service_name: Uri,
78    pub application_name: Uri,
79}