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
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
/// Postgres input connector configuration.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
pub struct PostgresReaderConfig {
/// Postgres URI.
/// See: <https://docs.rs/tokio-postgres/0.7.12/tokio_postgres/config/struct.Config.html>
pub uri: String,
/// Query that specifies what data to fetch from postgres.
pub query: String,
}
/// Postgres output connector configuration.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
pub struct PostgresWriterConfig {
/// Postgres URI.
/// See: <https://docs.rs/tokio-postgres/0.7.12/tokio_postgres/config/struct.Config.html>
pub uri: String,
/// The table to write the output to.
pub table: String,
/// A sequence of CA certificates in PEM format.
pub ssl_ca_pem: Option<String>,
/// Path to a file containing a sequence of CA certificates in PEM format.
pub ssl_ca_location: Option<String>,
/// The client certificate in PEM format.
pub ssl_client_pem: Option<String>,
/// Path to the client certificate.
pub ssl_client_location: Option<String>,
/// The client certificate key in PEM format.
pub ssl_client_key: Option<String>,
/// Path to the client certificate key.
pub ssl_client_key_location: Option<String>,
/// The path to the certificate chain file.
/// The file must contain a sequence of PEM-formatted certificates,
/// the first being the leaf certificate, and the remainder forming
/// the chain of certificates up to and including the trusted root certificate.
pub ssl_certificate_chain_location: Option<String>,
/// True to enable hostname verification when using TLS. True by default.
pub verify_hostname: Option<bool>,
/// The maximum number of records in a single buffer.
pub max_records_in_buffer: Option<usize>,
/// The maximum buffer size in for a single operation.
/// Note that the buffers of `INSERT`, `UPDATE` and `DELETE` queries are
/// separate.
/// Default: 1 MiB
#[schema(default = default_max_buffer_size)]
#[serde(default = "default_max_buffer_size")]
pub max_buffer_size_bytes: usize,
/// Specifies how the connector handles conflicts when executing an `INSERT`
/// into a table with a primary key. By default, an existing row with the same
/// key is overwritten. Setting this flag to `true` preserves the existing row
/// and ignores the new insert.
///
/// This setting does not affect `UPDATE` statements, which always replace the
/// value associated with the key.
///
/// Default: `false`
#[serde(default)]
pub on_conflict_do_nothing: bool,
}
fn default_max_buffer_size() -> usize {
usize::pow(2, 20)
}