pub struct PostgresSinkConfig {
pub connection_url: String,
pub table_name: String,
pub schema: Option<String>,
pub column_mapping: PostgresColumnMapping,
pub batch_size: usize,
pub max_connections: u32,
}Expand description
Configuration for the PostgreSQL sink.
Fields§
§connection_url: StringPostgreSQL connection URL (e.g. postgres://user:pass@host/db).
table_name: StringTarget table name.
schema: Option<String>Optional schema (namespace) qualifying table_name.
When set, both the AutoMap column-discovery probe and the INSERT
target schema.table_name explicitly. When unset (the default), the
table resolves against the connection’s search_path, and column
discovery is scoped to whichever schema the INSERT actually resolves
to — so a same-named table in another schema no longer pollutes the
AutoMap column set (#146 M13).
column_mapping: PostgresColumnMappingHow to map JSON records to columns.
batch_size: usizeMaximum rows per multi-row INSERT statement. Defaults to
DEFAULT_BATCH_SIZE.
When the upstream StreamPage carries more records than batch_size,
the sink slices the page into batch_size-row chunks and issues one
multi-row INSERT per chunk. When batch_size = 0, the entire slice
is sent in a single INSERT — useful when the source already chunks
to a Postgres-friendly size.
batch_size = 0 is the “no batching” sentinel: the entire upstream
page is forwarded in one statement, subject to Postgres’ natural
per-statement bind-parameter limit of 65 535. AutoMap mode binds one
parameter per column per row, so the safe ceiling is roughly
65_535 / num_columns rows per call; JSONB mode binds a single
array parameter and has no such ceiling. Keep the default unless the
upstream page size is already tuned for Postgres.
Recommended value: ~1000 — Postgres’ multi-row INSERT sweet
spot. Larger chunks rarely add throughput and risk hitting the
65 535-parameter ceiling in AutoMap mode.
max_connections: u32Maximum number of connections in the pool. Defaults to 5.
Implementations§
Source§impl PostgresSinkConfig
impl PostgresSinkConfig
Sourcepub fn new(
connection_url: impl Into<String>,
table_name: impl Into<String>,
) -> Self
pub fn new( connection_url: impl Into<String>, table_name: impl Into<String>, ) -> Self
Create a new config with required fields and sensible defaults.
Sourcepub fn with_schema(self, schema: impl Into<String>) -> Self
pub fn with_schema(self, schema: impl Into<String>) -> Self
Set the schema (namespace) that qualifies the table. When unset, the
table resolves against the connection’s search_path.
Sourcepub fn column_mapping(self, mapping: PostgresColumnMapping) -> Self
pub fn column_mapping(self, mapping: PostgresColumnMapping) -> Self
Set the column mapping strategy.
Sourcepub fn with_batch_size(self, batch_size: usize) -> Self
pub fn with_batch_size(self, batch_size: usize) -> Self
Set the per-statement row count for multi-row INSERT.
Pass 0 to opt out of re-chunking — the sink forwards each upstream
StreamPage as a single INSERT
statement. Postgres’ multi-row INSERT sweet spot is ~1000 rows.
Sourcepub fn max_connections(self, n: u32) -> Self
pub fn max_connections(self, n: u32) -> Self
Set the maximum number of connections in the pool.
Trait Implementations§
Source§impl Clone for PostgresSinkConfig
impl Clone for PostgresSinkConfig
Source§fn clone(&self) -> PostgresSinkConfig
fn clone(&self) -> PostgresSinkConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PostgresSinkConfig
impl Debug for PostgresSinkConfig
Source§impl<'de> Deserialize<'de> for PostgresSinkConfig
impl<'de> Deserialize<'de> for PostgresSinkConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for PostgresSinkConfig
impl JsonSchema for PostgresSinkConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for PostgresSinkConfig
impl RefUnwindSafe for PostgresSinkConfig
impl Send for PostgresSinkConfig
impl Sync for PostgresSinkConfig
impl Unpin for PostgresSinkConfig
impl UnsafeUnpin for PostgresSinkConfig
impl UnwindSafe for PostgresSinkConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more