Skip to main content

feldera_types/transport/
http.rs

1use crate::coordination::Step;
2use serde::{Deserialize, Serialize};
3use serde_json::Value as JsonValue;
4use utoipa::ToSchema;
5
6/// Configuration for data output via HTTP.
7///
8/// HTTP output adapters cannot be usefully configured as part of pipeline
9/// configuration.  Instead, instantiate them through the REST API as
10/// `/pipelines/{pipeline_name}/egress`.
11#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize, ToSchema)]
12#[serde(default)]
13pub struct HttpOutputConfig {
14    /// Apply backpressure on the pipeline when the HTTP client cannot receive
15    /// data fast enough.
16    ///
17    /// When this flag is set to false (the default), the HTTP connector drops data
18    /// chunks if the client is not keeping up with its output.  This prevents
19    /// a slow HTTP client from slowing down the entire pipeline.
20    ///
21    /// When the flag is set to true, the connector waits for the client to receive
22    /// each chunk and blocks the pipeline if the client cannot keep up.
23    pub backpressure: bool,
24}
25
26/// Configuration for data input via HTTP.
27///
28/// HTTP input adapters cannot be usefully configured as part of pipeline
29/// configuration.  Instead, instantiate them through the REST API as
30/// `/pipelines/{pipeline_name}/ingress/{table_name}`.
31#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, ToSchema)]
32pub struct HttpInputConfig {
33    /// Autogenerated name.
34    pub name: String,
35}
36
37/// A set of updates to a SQL table or view.
38///
39/// The `sequence_number` field stores the offset of the chunk relative to the
40/// start of the stream and can be used to implement reliable delivery.
41/// The payload is stored in the `bin_data`, `text_data`, or `json_data` field
42/// depending on the data format used.  A chunk without a payload marks the
43/// end of a step's output, when it carries `processed_steps`, or is a
44/// keep-alive.
45#[derive(Deserialize, ToSchema)]
46pub struct Chunk {
47    pub sequence_number: u64,
48    /// `true` when this chunk is part of the initial snapshot delivered in
49    /// `send_snapshot` mode; `false` for incremental delta updates.
50    pub snapshot: bool,
51
52    /// The number of steps whose output precedes this chunk, this step
53    /// included.  `Some` only on the empty chunk that follows a step's output,
54    /// so a chunk with `processed_steps` carries no `bin_data`, `text_data`
55    /// or `json_data`.  The output of a record that the pipeline ingested in
56    /// step `n` has been delivered once `processed_steps > n`.  The
57    /// `/completion_status` endpoint reports the `step` that a completion
58    /// token waits for in the same unit, so a client that has received a
59    /// chunk with `processed_steps` at or above that `step` is guaranteed to
60    /// have received every update for the token.
61    #[schema(value_type = Option<u64>)]
62    pub processed_steps: Option<Step>,
63
64    // Exactly one of the following fields must be set.
65    // This should be an enum inlined with `#[serde(flatten)]`, but `utoipa`
66    // struggles to generate a schema for that.
67    /// Base64 encoded binary payload, e.g., bincode.
68    pub bin_data: Option<Vec<u8>>,
69
70    /// Text payload, e.g., CSV.
71    pub text_data: Option<String>,
72
73    /// JSON payload.
74    #[schema(value_type = Option<Object>)]
75    pub json_data: Option<JsonValue>,
76}
77
78// This file indicates the port used by the server
79pub const SERVER_PORT_FILE: &str = "port";