1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! Types for the query parameters of the pipeline endpoints.
use serde::{Deserialize, Serialize};
use utoipa::{IntoParams, ToSchema};
use crate::runtime_status::RuntimeDesiredStatus;
/// Circuit metrics output format.
/// - `prometheus`: [format](https://github.com/prometheus/docs/blob/4b1b80f5f660a2f8dc25a54f52a65a502f31879a/docs/instrumenting/exposition_formats.md) expected by Prometheus
/// - `json`: JSON format
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum MetricsFormat {
Prometheus,
Json,
}
/// Returns default metrics format.
fn default_metrics_format() -> MetricsFormat {
MetricsFormat::Prometheus
}
/// Query parameters to retrieve pipeline circuit metrics.
#[derive(Debug, Deserialize, IntoParams, ToSchema)]
pub struct MetricsParameters {
#[serde(default = "default_metrics_format")]
pub format: MetricsFormat,
}
#[derive(Debug, Deserialize, IntoParams, ToSchema)]
#[serde(default)]
pub struct ActivateParams {
#[serde(with = "crate::runtime_status::snake_case_runtime_desired_status")]
pub initial: RuntimeDesiredStatus,
}
impl Default for ActivateParams {
fn default() -> Self {
Self {
initial: RuntimeDesiredStatus::Running,
}
}
}
#[derive(Debug, Deserialize, Serialize, IntoParams, ToSchema)]
#[serde(default)]
pub struct SamplyProfileParams {
/// In a multihost pipeline, the ordinal of the pipeline to sample.
pub ordinal: usize,
/// The number of seconds to sample for the profile, from 1 to 300.
pub duration_secs: u64,
}
impl SamplyProfileParams {
/// The longest profile a caller can request, in seconds.
pub const MAX_DURATION_SECS: u64 = 300;
}
/// Default query parameters for POST of a pipeline samply profile.
impl Default for SamplyProfileParams {
fn default() -> Self {
Self {
ordinal: 0,
duration_secs: 30,
}
}
}
/// Query parameters to retrieve samply profile.
#[derive(Debug, Default, Deserialize, Serialize, IntoParams, ToSchema)]
#[into_params(parameter_in = Query)]
#[serde(default)]
pub struct SamplyProfileGetParams {
/// In a multihost pipeline, the ordinal of the pipeline to sample.
pub ordinal: usize,
/// If true, returns 204 redirect with Retry-After header if profile collection is in progress.
/// If false or not provided, returns the last collected profile.
pub latest: bool,
}
/// Query parameters to the `/commit_transaction` endpoint.
#[derive(Debug, Default, Deserialize, Serialize, IntoParams, ToSchema)]
#[into_params(parameter_in = Query)]
#[serde(default)]
pub struct CommitTransactionParams {
/// The ID of the transaction to commit, which `/start_transaction`
/// returned:
///
/// - If this is the transaction that the API started and that is still
/// open, the request commits it.
/// - If this is the last transaction that `/commit_transaction`
/// committed, the request succeeds and does nothing, so it is safe to
/// retry.
/// - Otherwise, the request fails with 409 Conflict, for example if no
/// transaction with this ID has started yet.
///
/// Without this parameter, the request commits the transaction that the
/// API started.
#[param(value_type = Option<i64>)]
#[schema(value_type = Option<i64>)]
pub transaction_id: Option<crate::transaction::TransactionId>,
/// The `incarnation_uuid` that `/start_transaction` returned. If the
/// pipeline restarted since then, the request fails with 400 Bad Request
/// and error code `IncarnationUuidMismatch`, because transaction IDs start
/// again after a restart.
pub incarnation_uuid: Option<uuid::Uuid>,
}
/// Query parameters to the `/approve` endpoint.
#[derive(Debug, Deserialize, IntoParams, ToSchema)]
pub struct ApproveParameters {
/// Bootstrap the pipeline with output connectors disabled.
#[serde(default)]
pub silent_bootstrap: bool,
/// Bootstrap new and modified views concurrently, keeping the pre-existing
/// views live while the new ones backfill. Mutually exclusive with
/// `silent_bootstrap`.
#[serde(default)]
pub concurrent_bootstrap: bool,
}
/// Query parameters to the `/stats` endpoint.
#[derive(Debug, Default, Deserialize, Serialize, IntoParams, ToSchema)]
#[into_params(parameter_in = Query)]
pub struct StatsParams {
/// When `true`, the response includes the most recent error messages of
/// each connector. An error message can contain values from the record
/// that caused it. The default is `false`, which keeps the response small
/// for callers that poll `/stats`.
#[serde(default)]
pub include_connector_errors: bool,
}