Skip to main content

feldera_types/
query_params.rs

1//! Types for the query parameters of the pipeline endpoints.
2
3use serde::{Deserialize, Serialize};
4use utoipa::{IntoParams, ToSchema};
5
6use crate::runtime_status::RuntimeDesiredStatus;
7
8/// Circuit metrics output format.
9/// - `prometheus`: [format](https://github.com/prometheus/docs/blob/4b1b80f5f660a2f8dc25a54f52a65a502f31879a/docs/instrumenting/exposition_formats.md) expected by Prometheus
10/// - `json`: JSON format
11#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, ToSchema)]
12#[serde(rename_all = "snake_case")]
13pub enum MetricsFormat {
14    Prometheus,
15    Json,
16}
17
18/// Returns default metrics format.
19fn default_metrics_format() -> MetricsFormat {
20    MetricsFormat::Prometheus
21}
22
23/// Query parameters to retrieve pipeline circuit metrics.
24#[derive(Debug, Deserialize, IntoParams, ToSchema)]
25pub struct MetricsParameters {
26    #[serde(default = "default_metrics_format")]
27    pub format: MetricsFormat,
28}
29
30#[derive(Debug, Deserialize, IntoParams, ToSchema)]
31#[serde(default)]
32pub struct ActivateParams {
33    #[serde(with = "crate::runtime_status::snake_case_runtime_desired_status")]
34    pub initial: RuntimeDesiredStatus,
35}
36
37impl Default for ActivateParams {
38    fn default() -> Self {
39        Self {
40            initial: RuntimeDesiredStatus::Running,
41        }
42    }
43}
44
45#[derive(Debug, Deserialize, Serialize, IntoParams, ToSchema)]
46#[serde(default)]
47pub struct SamplyProfileParams {
48    /// In a multihost pipeline, the ordinal of the pipeline to sample.
49    pub ordinal: usize,
50    /// The number of seconds to sample for the profile.
51    pub duration_secs: u64,
52}
53
54/// Default query parameters for POST of a pipeline samply profile.
55impl Default for SamplyProfileParams {
56    fn default() -> Self {
57        Self {
58            ordinal: 0,
59            duration_secs: 30,
60        }
61    }
62}
63
64/// Query parameters to retrieve samply profile.
65#[derive(Debug, Default, Deserialize, Serialize, IntoParams, ToSchema)]
66#[into_params(parameter_in = Query)]
67#[serde(default)]
68pub struct SamplyProfileGetParams {
69    /// In a multihost pipeline, the ordinal of the pipeline to sample.
70    pub ordinal: usize,
71    /// If true, returns 204 redirect with Retry-After header if profile collection is in progress.
72    /// If false or not provided, returns the last collected profile.
73    pub latest: bool,
74}