feldera-types 0.376.0

Public API types for Feldera
Documentation
use crate::coordination::Step;
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use utoipa::ToSchema;

/// Configuration for data output via HTTP.
///
/// HTTP output adapters cannot be usefully configured as part of pipeline
/// configuration.  Instead, instantiate them through the REST API as
/// `/pipelines/{pipeline_name}/egress`.
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize, ToSchema)]
#[serde(default)]
pub struct HttpOutputConfig {
    /// Apply backpressure on the pipeline when the HTTP client cannot receive
    /// data fast enough.
    ///
    /// When this flag is set to false (the default), the HTTP connector drops data
    /// chunks if the client is not keeping up with its output.  This prevents
    /// a slow HTTP client from slowing down the entire pipeline.
    ///
    /// When the flag is set to true, the connector waits for the client to receive
    /// each chunk and blocks the pipeline if the client cannot keep up.
    pub backpressure: bool,
}

/// Configuration for data input via HTTP.
///
/// HTTP input adapters cannot be usefully configured as part of pipeline
/// configuration.  Instead, instantiate them through the REST API as
/// `/pipelines/{pipeline_name}/ingress/{table_name}`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, ToSchema)]
pub struct HttpInputConfig {
    /// Autogenerated name.
    pub name: String,
}

/// A set of updates to a SQL table or view.
///
/// The `sequence_number` field stores the offset of the chunk relative to the
/// start of the stream and can be used to implement reliable delivery.
/// The payload is stored in the `bin_data`, `text_data`, or `json_data` field
/// depending on the data format used.  A chunk without a payload marks the
/// end of a step's output, when it carries `processed_steps`, or is a
/// keep-alive.
#[derive(Deserialize, ToSchema)]
pub struct Chunk {
    pub sequence_number: u64,
    /// `true` when this chunk is part of the initial snapshot delivered in
    /// `send_snapshot` mode; `false` for incremental delta updates.
    pub snapshot: bool,

    /// The number of steps whose output precedes this chunk, this step
    /// included.  `Some` only on the empty chunk that follows a step's output,
    /// so a chunk with `processed_steps` carries no `bin_data`, `text_data`
    /// or `json_data`.  The output of a record that the pipeline ingested in
    /// step `n` has been delivered once `processed_steps > n`.  The
    /// `/completion_status` endpoint reports the `step` that a completion
    /// token waits for in the same unit, so a client that has received a
    /// chunk with `processed_steps` at or above that `step` is guaranteed to
    /// have received every update for the token.
    #[schema(value_type = Option<u64>)]
    pub processed_steps: Option<Step>,

    // Exactly one of the following fields must be set.
    // This should be an enum inlined with `#[serde(flatten)]`, but `utoipa`
    // struggles to generate a schema for that.
    /// Base64 encoded binary payload, e.g., bincode.
    pub bin_data: Option<Vec<u8>>,

    /// Text payload, e.g., CSV.
    pub text_data: Option<String>,

    /// JSON payload.
    #[schema(value_type = Option<Object>)]
    pub json_data: Option<JsonValue>,
}

// This file indicates the port used by the server
pub const SERVER_PORT_FILE: &str = "port";