singer_sdk.RecordSink¶
- class singer_sdk.RecordSink[source]¶
Base class for singleton record writers.
This class supports both legacy and modern loading patterns:
- Legacy pattern (deprecated but supported):
Override process_record(record: dict, context: dict) to load each record
- Modern pattern (recommended):
Override load_record(record: dict) for cleaner, simpler immediate loading
- Example (modern pattern):
- class MyRecordSink(RecordSink):
- def load_record(self, record: dict) -> None:
# Clear, simple loading self.api_client.post(record)
- Example (legacy pattern - still works):
- class MyLegacySink(RecordSink):
- def process_record(self, record: dict, context: dict) -> None:
# Old style - context is unused for RecordSink self.api_client.post(record)
- load_record(record)[source]¶
Load a single record immediately to the target.
Modern pattern (recommended): Override this method for cleaner, simpler immediate record loading.
This method provides a cleaner alternative to
process_record(). It takes only the record (no context dict), making the intent clear and reducing complexity.Example
- class MyRecordSink(RecordSink):
- def load_record(self, record: dict) -> None:
# Simple, clear loading self.api_client.post(“/endpoint”, json=record)
- Parameters:
record (dict) – The record to load immediately.
- Return type:
None
Note
If you override this method, you do NOT need to override
process_record(). The framework will automatically call this method instead.
- final process_batch(context)[source]¶
Do nothing and return immediately.
The RecordSink class does not support batching.
This method may not be overridden.
- Parameters:
context (dict) – Stream partition or context dictionary.
- Return type:
None
- process_record(record, context)[source]¶
Load the latest record from the stream.
Legacy pattern (deprecated but supported): Override this method for dict-based record loading with context.
Modern pattern (recommended): Override
load_record()instead for simpler, clearer immediate loading.If you override
load_record(), you do NOT need to override this method. The framework will automatically route to yourload_record()implementation.Implementations should permanently serialize each record to the target prior to returning.
If duplicates are merged/skipped instead of being loaded, merges can be tracked via
tally_duplicate_merged().- Parameters:
- Raises:
NotImplementedError – If neither process_record nor load_record is overridden.
- Return type:
None