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    /// A sequence of CA certificates in PEM format.
26    pub ssl_ca_pem: Option<String>,
27
28    /// Path to a file containing a sequence of CA certificates in PEM format.
29    pub ssl_ca_location: Option<String>,
30
31    /// The client certificate in PEM format.
32    pub ssl_client_pem: Option<String>,
33
34    /// Path to the client certificate.
35    pub ssl_client_location: Option<String>,
36
37    /// The client certificate key in PEM format.
38    pub ssl_client_key: Option<String>,
39
40    /// Path to the client certificate key.
41    pub ssl_client_key_location: Option<String>,
42
43    /// The path to the certificate chain file.
44    /// The file must contain a sequence of PEM-formatted certificates,
45    /// the first being the leaf certificate, and the remainder forming
46    /// the chain of certificates up to and including the trusted root certificate.
47    pub ssl_certificate_chain_location: Option<String>,
48
49    /// True to enable hostname verification when using TLS. True by default.
50    pub verify_hostname: Option<bool>,
51
52    /// The maximum number of records in a single buffer.
53    pub max_records_in_buffer: Option<usize>,
54
55    /// The maximum buffer size in for a single operation.
56    /// Note that the buffers of `INSERT`, `UPDATE` and `DELETE` queries are
57    /// separate.
58    /// Default: 1 MiB
59    #[schema(default = default_max_buffer_size)]
60    #[serde(default = "default_max_buffer_size")]
61    pub max_buffer_size_bytes: usize,
62
63    /// Specifies how the connector handles conflicts when executing an `INSERT`
64    /// into a table with a primary key. By default, an existing row with the same
65    /// key is overwritten. Setting this flag to `true` preserves the existing row
66    /// and ignores the new insert.
67    ///
68    /// This setting does not affect `UPDATE` statements, which always replace the
69    /// value associated with the key.
70    ///
71    /// Default: `false`
72    #[serde(default)]
73    pub on_conflict_do_nothing: bool,
74}
75
76fn default_max_buffer_size() -> usize {
77    usize::pow(2, 20)
78}