feldera_types/transport/
postgres.rs

1use serde::{Deserialize, Serialize};
2use utoipa::ToSchema;
3
4/// Postgres input connector configuration.
5#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
6pub struct PostgresReaderConfig {
7    /// Postgres URI.
8    /// See: <https://docs.rs/tokio-postgres/0.7.12/tokio_postgres/config/struct.Config.html>
9    pub uri: String,
10
11    /// Query that specifies what data to fetch from postgres.
12    pub query: String,
13}
14
15/// Postgres output connector configuration.
16#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
17pub struct PostgresWriterConfig {
18    /// Postgres URI.
19    /// See: <https://docs.rs/tokio-postgres/0.7.12/tokio_postgres/config/struct.Config.html>
20    pub uri: String,
21
22    /// The table to write the output to.
23    pub table: String,
24
25    /// The CA certificate in PEM format.
26    pub ssl_ca_pem: Option<String>,
27
28    /// The client certificate in PEM format.
29    pub ssl_client_pem: Option<String>,
30
31    /// The client certificate key in PEM format.
32    pub ssl_client_key: Option<String>,
33
34    /// True to enable hostname verification when using TLS. True by default.
35    pub verify_hostname: Option<bool>,
36
37    /// The maximum number of records in a single buffer.
38    pub max_records_in_buffer: Option<usize>,
39
40    /// The maximum buffer size in for a single operation.
41    /// Note that the buffers of `INSERT`, `UPDATE` and `DELETE` queries are
42    /// separate.
43    /// Default: 1 MiB
44    #[schema(default = default_max_buffer_size)]
45    #[serde(default = "default_max_buffer_size")]
46    pub max_buffer_size_bytes: usize,
47
48    /// Specifies how the connector handles conflicts when executing an `INSERT`
49    /// into a table with a primary key. By default, an existing row with the same
50    /// key is overwritten. Setting this flag to `true` preserves the existing row
51    /// and ignores the new insert.
52    ///
53    /// This setting does not affect `UPDATE` statements, which always replace the
54    /// value associated with the key.
55    ///
56    /// Default: `false`
57    #[serde(default)]
58    pub on_conflict_do_nothing: bool,
59}
60
61fn default_max_buffer_size() -> usize {
62    usize::pow(2, 20)
63}