Start with one full-read source
The base interface is intentionally small:Configure can therefore keep a client,
connection pool, or parsed configuration on the struct, and Teardown releases
it when the run ends.
Extract is where data crosses into Filament. This minimal example writes two
columns for every requested resource:
Null() for a null value. EndRow closes the row and may block while a
full batch waits for the sink; returning its error is how backpressure and
pipeline failures reach the source.
The pipeline closes builders after extraction. A source normally calls neither
Close nor Drain; those are lifecycle details for advanced resumable or CDC
sources. A long-lived stream may call Flush when it goes idle and needs to
send a partially filled batch.Resources and parts
A builder belongs to one(resource, part) pair. Most sources start with part
0. A source that splits a large table into independently read ranges opens
one builder per range and assigns each a stable part number.
ExtractOpts.Parallelism is the run’s concurrency budget, not an instruction
to create that many parts. The source decides whether its backend can safely
read in parallel. Each builder must be written by only one goroutine.
Row metadata for recovery and CDC
Most full-read sources can pass an emptyRowMeta. Recovery and CDC sources use
it to carry information that travels with a row without becoming a
destination column:
Opis insert, update, or delete. Full reads normally leave it at insert.Keyis the source position for a keyset-resumable part.Coarsemarks progress that can only be acknowledged by row count.LSNandSeqorder a CDC stream.
Describe and register the source
Spec supplies the catalog name, configuration fields, and supported read
policies. Keep the advertisement aligned with behavior: advertising incremental
or CDC support does not implement the corresponding extraction interfaces.
Register a factory so each run receives a fresh instance:
alpha, then
raise maturity when the connector has been exercised end to end.
Add capabilities deliberately
A useful next step isDiscoverable, which lets users browse resources before
creating a pipeline. A SchemaProvider is required when the source must feed a
schema-aware sink.
Resume, incremental reads, and CDC require several contracts to work together;
they are not single-interface switches. See
Optional interfaces
for those capability sets.
The repository’s connectors/sample
package is the smallest complete source. It demonstrates the same builder flow
without an external dependency.