Skip to main content

feldera_types/
query_params.rs

1//! Types for the query parameters of the pipeline endpoints.
2
3use serde::Deserialize;
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, IntoParams, ToSchema)]
46pub struct SamplyProfileParams {
47    #[serde(default = "default_samply_profile_duration")]
48    pub duration_secs: u64,
49}
50
51/// Default for the `duration_secs` query parameter when POST a pipeline samply profile.
52fn default_samply_profile_duration() -> u64 {
53    30
54}
55
56/// Query parameters to retrieve samply profile.
57#[derive(Debug, Deserialize, IntoParams, ToSchema)]
58#[into_params(parameter_in = Query)]
59pub struct SamplyProfileGetParams {
60    /// If true, returns 204 redirect with Retry-After header if profile collection is in progress.
61    /// If false or not provided, returns the last collected profile.
62    #[serde(default)]
63    pub latest: bool,
64}