Expand description
Family driver traits (RFC 0014, #895).
A driver is a connector’s I/O and nothing else. The engine — this module
for the family-neutral contract, faucet-common-sql and
faucet-common-file for the SQL and object-store families — drives every
lifecycle from the driver’s primitives: overwrite staging, the
exactly-once commit, scoped cleanup, rollback, per-row outcomes and the row
report. A connector built on a driver cannot get one of those contracts
wrong by forgetting a hook, because it does not implement the hook.
| Layer | Trait | Adapter to Sink / Source |
|---|---|---|
| any sink | SinkDriver (+ StagingDriver, CommitTokenDriver, CleanupDriver, SchemaDriver, RollbackDriver) | DriverSink |
| any source | SourceDriver | DriverSource |
| messaging, produce | MessageDriver (+ MessageTransactions) | MessageSinkDriver → DriverSink |
| messaging, consume | MessageConsumer | MessageSourceDriver → DriverSource |
| HTTP | HttpDriver | HttpSinkDriver → DriverSink |
| SQL | faucet_common_sql::SqlDriver | faucet_common_sql::SqlSinkDriver → DriverSink |
| object storage | faucet_common_file::ObjectStoreDriver | faucet_common_file::FileSink (a DriverSink inside) |
The SQL and object-store traits live in their family crates because they
are built on those crates’ engines (SqlSinkEngine / SqlDialect,
FileWriter / StorageBackend), and faucet-core depends on no
connector-family crate.
Values. Drivers exchange JSON Value records under the
value-fidelity rules (#885); a destination that writes Arrow directly adds
a ColumnarDriver (feature arrow) and receives the
RecordBatch unconverted.
Calls. Every async primitive receives the run’s
CallSlot; the adapter installs the run’s context into
it. Make each backend request through it.
Migrating a connector. Keep the public type and config; hold the adapter and forward:
use faucet_core::driver::{DriverSink, PageWrite, RowPolicy, SinkDriver};
use faucet_core::{CallSlot, FaucetError, Sink, Value, async_trait, forward_sink};
/// The connector's I/O.
struct AcmeDriver;
#[async_trait]
impl SinkDriver for AcmeDriver {
fn connector_name(&self) -> &'static str {
"acme"
}
async fn write(
&self,
calls: &CallSlot,
rows: &[Value],
_policy: RowPolicy,
) -> Result<PageWrite, FaucetError> {
let n = rows.len();
calls
.call_once("insert", async move { Ok::<_, FaucetError>(n) })
.await?;
Ok(PageWrite::accepted(n))
}
}
/// The public connector type, unchanged for its users.
pub struct AcmeSink {
inner: DriverSink<AcmeDriver>,
}
#[async_trait]
impl Sink for AcmeSink {
forward_sink!(inner);
}See RFC 0014 for the deprecated hooks these traits replace and the migration guide.
Structs§
- AckToken
- An opaque handle a consumer acknowledges a message by.
- Driver
Sink - A
SinkDriveras aSink(RFC 0014). - Driver
Source - A
SourceDriveras aSource(RFC 0014): every fetch is the driver’s page stream, and the run’s call context reaches every read. - Http
Sink Driver - An
HttpDriveras aSinkDriver. - Inbound
Message - One received message.
- Message
Sink Driver - A
MessageDriveras aSinkDriver. - Message
Source Driver - A
MessageConsumeras aSourceDriver. - Outbound
Message - One message to publish.
- Page
Write - What one
SinkDriver::writedid.
Enums§
- Http
Batching - How a page becomes requests.
- RowPolicy
- How a write may report a row it could not write.
Traits§
- Cleanup
Driver - The scoped-cleanup primitive of a destination (#478).
- Columnar
Driver arrow - The columnar write primitive of a destination that writes Arrow directly.
- Commit
Token Driver - The exactly-once primitives of a destination: rows and a commit token committed as one unit (#215).
- Http
Driver - An HTTP destination’s primitives (RFC 0014). Wrap it in an
HttpSinkDriver, then aDriverSink. - Message
Consumer - A consumer’s primitives (RFC 0014). Wrap it in a
MessageSourceDriver, then aDriverSource. - Message
Driver - A producer’s primitives (RFC 0014). Wrap it in a
MessageSinkDriver, then aDriverSink. - Message
Transactions - A producer’s transaction primitives. With them,
MessageSinkDrivercommits a page’s messages and its commit token in one transaction. - Rollback
Driver - The run-rollback primitives of a destination (#706).
- Schema
Driver - The schema primitives of a destination (#194).
- Sink
Driver - A destination’s I/O primitives (RFC 0014). Wrap it in a
DriverSinkto get aSink. - Source
Driver - A dataset’s read primitives (RFC 0014). Wrap it in a
DriverSourceto get aSource. - Staging
Driver - The overwrite (full refresh) primitives of a destination (#492).
Functions§
- pages_
of - Split a buffered read into pages of
batch_sizerecords (0: one page), the bookmark on the last page — the shape a source without a native paging primitive streams in. An empty read yields one empty page only when it carries a bookmark.
Type Aliases§
- Columnar
Stream arrow - A stream of Arrow pages a
SourceDriverreads. - Native
Stream - A stream of raw byte batches a
SourceDriverreads. - Page
Stream - A stream of pages a
SourceDriverreads.