Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new methods to extract fields in PartitionLoadInformation #85

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion crates/libs/core/src/types/client/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
types::{HealthState, ServicePartitionInformation},
};

use super::metrics::{PrimaryLoadMetricReportList, SecondaryLoadMetricReportList};
use super::metrics::{LoadMetricReport, PrimaryLoadMetricReportList, SecondaryLoadMetricReportList};

// Partition related types
// FABRIC_SERVICE_PARTITION_QUERY_DESCRIPTION
Expand Down Expand Up @@ -217,6 +217,7 @@ pub struct PartitionLoadInformation {
}

impl PartitionLoadInformation {
/// Constructs the partition load information from the COM owner
pub fn new(com: IFabricGetPartitionLoadInformationResult) -> Self {
let partition_id = unsafe {
com.get_PartitionLoadInformation()
Expand All @@ -233,4 +234,25 @@ impl PartitionLoadInformation {
secondary_load_metric_reports,
}
}

/// Returns the partition id
pub fn partition_id(&self) -> GUID {
self.partition_id
}

/// Returns a list of load metric reports for primary replica
pub fn primary_load_metric_reports(&self) -> Vec<LoadMetricReport> {
self
.primary_load_metric_reports
.iter()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just return the PrimaryLoadMetricReportList. make the field private.
mssf api prefers not use Vec or other types that requires dynamic alloc for list.

.collect::<Vec<_>>()
}

/// Returns a list of the load metric reports for secondary replica
pub fn secondary_load_metric_reports(&self) -> Vec<LoadMetricReport> {
self
.secondary_load_metric_reports
.iter()
.collect::<Vec<_>>()
}
}
Loading