stream_writer_convenience
sqllocks_spindle.fabric.stream_writer_convenience
¶
High-level convenience wrapper for streaming Spindle data to Fabric Eventstream.
Wraps :class:SpindleStreamer + :class:EventstreamClient into a single
class with sensible defaults, designed for use in Fabric Notebooks.
Requires the streaming extra::
pip install sqllocks-spindle[streaming]
Usage::
from sqllocks_spindle.fabric import FabricStreamWriter
writer = FabricStreamWriter(
connection_string="Endpoint=sb://...;SharedAccessKeyName=...;SharedAccessKey=...",
domain="retail",
table="order",
)
result = writer.stream(max_events=1000, rate=100.0)
print(f"Streamed {result.events_sent:,} events in {result.elapsed_seconds:.1f}s")
Classes¶
FabricStreamWriter
¶
Stream Spindle-generated events to Fabric Eventstream or Event Hub.
Combines domain generation, streaming engine, anomaly injection, and the EventstreamClient sink into a single high-level API call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection_string
|
str
|
Event Hub-compatible connection string for the Eventstream custom endpoint. |
required |
domain
|
str
|
Domain name (e.g. |
'retail'
|
table
|
str
|
Table/entity name to stream (e.g. |
'order'
|
scale
|
str
|
Scale preset for data generation (default |
'small'
|
eventhub_name
|
str | None
|
Optional Event Hub name (if not in connection string). |
None
|
partition_key_column
|
str | None
|
Column to partition events by for ordered delivery. |
None
|
Example (Fabric Notebook)::
writer = FabricStreamWriter(
connection_string="Endpoint=sb://...",
domain="retail",
table="order",
scale="small",
)
# Stream 5,000 events at 200 eps with 5% anomalies
result = writer.stream(max_events=5000, rate=200.0, anomaly_rate=0.05)
print(result)
Methods:¶
stream(max_events=1000, rate=100.0, anomaly_rate=0.05, burst=None, out_of_order=0.0, seed=42, realtime=True)
¶
Stream events to the configured Eventstream endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_events
|
int
|
Total events to stream. |
1000
|
rate
|
float
|
Baseline rate in events per second. |
100.0
|
anomaly_rate
|
float
|
Fraction of events to flag as anomalous (0.0-1.0). |
0.05
|
burst
|
str | None
|
Optional burst spec as |
None
|
out_of_order
|
float
|
Fraction of events to deliberately reorder (0.0-1.0). |
0.0
|
seed
|
int
|
Random seed for reproducibility. |
42
|
realtime
|
bool
|
Rate-limit output to the target rate (default True). |
True
|
Returns:
| Type | Description |
|---|---|
Any
|
class: |
Any
|
event counts, anomaly stats, and timing. |