use crate::InternalError;
use super::{
directory::{
DirectoryMetricOperation, DirectoryMetricOutcome, DirectoryMetricReason, DirectoryMetrics,
},
pool::{PoolMetricOperation, PoolMetricOutcome, PoolMetricReason, PoolMetrics},
scaling::{ScalingMetricOperation, ScalingMetricOutcome, ScalingMetricReason, ScalingMetrics},
};
#[cfg(feature = "sharding")]
use super::sharding::{
ShardingMetricOperation, ShardingMetricOutcome, ShardingMetricReason, ShardingMetrics,
};
pub struct DirectoryMetricEvent;
impl DirectoryMetricEvent {
pub fn record(
operation: DirectoryMetricOperation,
outcome: DirectoryMetricOutcome,
reason: DirectoryMetricReason,
) {
DirectoryMetrics::record(operation, outcome, reason);
}
pub fn started(operation: DirectoryMetricOperation) {
Self::record(
operation,
DirectoryMetricOutcome::Started,
DirectoryMetricReason::Ok,
);
}
pub fn completed(operation: DirectoryMetricOperation, reason: DirectoryMetricReason) {
Self::record(operation, DirectoryMetricOutcome::Completed, reason);
}
pub fn skipped(operation: DirectoryMetricOperation, reason: DirectoryMetricReason) {
Self::record(operation, DirectoryMetricOutcome::Skipped, reason);
}
pub fn failed(operation: DirectoryMetricOperation, err: &InternalError) {
Self::record(
operation,
DirectoryMetricOutcome::Failed,
DirectoryMetricReason::from_error(err),
);
}
pub fn failed_reason(operation: DirectoryMetricOperation, reason: DirectoryMetricReason) {
Self::record(operation, DirectoryMetricOutcome::Failed, reason);
}
}
pub struct PoolMetricEvent;
impl PoolMetricEvent {
pub fn record(
operation: PoolMetricOperation,
outcome: PoolMetricOutcome,
reason: PoolMetricReason,
) {
PoolMetrics::record(operation, outcome, reason);
}
pub fn started(operation: PoolMetricOperation) {
Self::record(operation, PoolMetricOutcome::Started, PoolMetricReason::Ok);
}
pub fn completed(operation: PoolMetricOperation, reason: PoolMetricReason) {
Self::record(operation, PoolMetricOutcome::Completed, reason);
}
pub fn skipped(operation: PoolMetricOperation, reason: PoolMetricReason) {
Self::record(operation, PoolMetricOutcome::Skipped, reason);
}
pub fn failed(operation: PoolMetricOperation, err: &InternalError) {
Self::record(
operation,
PoolMetricOutcome::Failed,
PoolMetricReason::from_error(err),
);
}
}
pub struct ScalingMetricEvent;
impl ScalingMetricEvent {
pub fn record(
operation: ScalingMetricOperation,
outcome: ScalingMetricOutcome,
reason: ScalingMetricReason,
) {
ScalingMetrics::record(operation, outcome, reason);
}
pub fn started(operation: ScalingMetricOperation) {
Self::record(
operation,
ScalingMetricOutcome::Started,
ScalingMetricReason::Ok,
);
}
pub fn completed(operation: ScalingMetricOperation, reason: ScalingMetricReason) {
Self::record(operation, ScalingMetricOutcome::Completed, reason);
}
pub fn skipped(operation: ScalingMetricOperation, reason: ScalingMetricReason) {
Self::record(operation, ScalingMetricOutcome::Skipped, reason);
}
pub fn failed(operation: ScalingMetricOperation, err: &InternalError) {
Self::record(
operation,
ScalingMetricOutcome::Failed,
ScalingMetricReason::from_error(err),
);
}
pub fn failed_reason(operation: ScalingMetricOperation, reason: ScalingMetricReason) {
Self::record(operation, ScalingMetricOutcome::Failed, reason);
}
}
#[cfg(feature = "sharding")]
pub struct ShardingMetricEvent;
#[cfg(feature = "sharding")]
impl ShardingMetricEvent {
pub fn record(
operation: ShardingMetricOperation,
outcome: ShardingMetricOutcome,
reason: ShardingMetricReason,
) {
ShardingMetrics::record(operation, outcome, reason);
}
pub fn started(operation: ShardingMetricOperation) {
Self::record(
operation,
ShardingMetricOutcome::Started,
ShardingMetricReason::Ok,
);
}
pub fn completed(operation: ShardingMetricOperation, reason: ShardingMetricReason) {
Self::record(operation, ShardingMetricOutcome::Completed, reason);
}
pub fn skipped(operation: ShardingMetricOperation, reason: ShardingMetricReason) {
Self::record(operation, ShardingMetricOutcome::Skipped, reason);
}
pub fn failed(operation: ShardingMetricOperation, err: &InternalError) {
Self::record(
operation,
ShardingMetricOutcome::Failed,
ShardingMetricReason::from_error(err),
);
}
pub fn failed_reason(operation: ShardingMetricOperation, reason: ShardingMetricReason) {
Self::record(operation, ShardingMetricOutcome::Failed, reason);
}
}