* feat(firehose): honor BufferingHints with time and size based flush Buffers now flush when the stream's BufferingHints.SizeInMBs is reached or when IntervalInSeconds has elapsed since the first buffered record, replacing the hardcoded 5-record count trigger that matched neither AWS nor LocalStack. A single-thread daemon flusher ticks every floci.services.firehose.tick-interval-seconds (default 10). Buffers are drained on ShutdownDelayInitiatedEvent so pending records reach S3 before EmulatorLifecycle persists storage to disk. DeleteDeliveryStream keeps discarding pending records, matching real AWS (verified empirically: 3 records buffered under a 300s/5MB hint never reached the bucket after deletion). Fixes #1886 * feat(firehose): add opt-in flush-record-count trigger Emulator-only volume trigger complementing BufferingHints: setting floci.services.firehose.flush-record-count to N flushes a stream's buffer as soon as it holds N records. Disabled by default (0) so out-of-the-box delivery matches real AWS; 1 gives LocalStack-style record-at-a-time delivery for interactive local dev, where stream definitions mirror production intervals and waiting for IntervalInSeconds is impractical. Covers the use case of #1852. Co-Authored-By: yoshinori-aono-om <yoshinori.aono@omiai.inc> * test(firehose): cover size and interval flush triggers at the wire level The size trigger delivers inline on the writing request, and the interval trigger runs through the real background flusher started on StartupEvent — previously only verified manually. The test-scope Clock is the frozen MutableClock alternative, so the interval test advances it explicitly instead of sleeping through real time. * fix(firehose): clamp the flush tick interval and mirror config keys in application.yml A zero or negative floci.services.firehose.tick-interval-seconds reached scheduleAtFixedRate unchanged, which throws IllegalArgumentException from the StartupEvent observer and aborts startup. Clamp it to a 1s minimum, the same guard RdsDataService applies to its cleanup interval. Also list tick-interval-seconds and flush-record-count under the firehose service in the main and test application.yml, matching how other tunable service settings are surfaced there. * test(firehose): wait for buffered delivery in DataLake and SES compatibility tests DataLakeTest relied on the removed 5-record flush: with buffered delivery its Athena query ran before anything reached S3, failing with NoSuchBucket on floci-firehose-results (caught by the compatibility CI job). Both tests now set explicit BufferingHints and poll for the delivered object first. A 5s interval keeps the wait short — floci does not enforce AWS's 60s server-side minimum and the SDK does no client-side range validation. --------- Co-authored-by: Mihai Blidaru <mihai.blidaru@lynxfctech.com>
3.7 KiB
Data Firehose
Protocol: JSON 1.1
Endpoint: http://localhost:4566/
Floci emulates Amazon Data Firehose for streaming data ingestion and delivery to S3.
Supported Actions
| Action | Description |
|---|---|
CreateDeliveryStream |
Creates a new delivery stream |
UpdateDestination |
- |
DescribeDeliveryStream |
Returns metadata about a stream |
ListDeliveryStreams |
Lists all delivery streams |
DeleteDeliveryStream |
Deletes a delivery stream |
PutRecord |
Writes a single data record to the stream |
PutRecordBatch |
Writes multiple data records to the stream |
TagDeliveryStream |
- |
UntagDeliveryStream |
- |
ListTagsForDeliveryStream |
- |
How it works
-
Buffering: Incoming records are buffered in memory.
-
Automatic Flush: A buffer is delivered to S3 when either trigger of the stream's
BufferingHintsfires first, mirroring AWS's buffered delivery:- the buffered records reach
SizeInMBs(default 5 MiB), or IntervalInSeconds(default 300 s) has elapsed since the first buffered record. A background flusher checks this everyfloci.services.firehose.tick-interval-seconds(default 10 s).
An emulator-only record-count trigger is also available for local dev: set
floci.services.firehose.flush-record-count(env:FLOCI_SERVICES_FIREHOSE_FLUSH_RECORD_COUNT) to flush after that many buffered records —1gives LocalStack-style record-at-a-time delivery. Disabled by default (0) so delivery timing matches real AWS.Buffers are also flushed on shutdown, so pending records are not lost. Deleting a delivery stream discards its pending records without flushing, matching real AWS.
- the buffered records reach
-
Format: Records are flushed as raw NDJSON (newline-delimited JSON) to the bucket configured in the S3 destination (
floci-firehose-resultsif the stream has no destination configuration).
S3 object keys
Delivered objects are named <evaluated prefix><streamName>-<versionId>-<yyyy-MM-dd-HH-mm-ss>-<uuid> (no file extension), matching AWS's object name format:
- Without a
Prefix, the default prefixyyyy/MM/dd/HH/is used. - A
Prefixwithout expressions getsyyyy/MM/dd/HH/appended by literal concatenation — no/is inserted, exactly like AWS (legacy→legacy2026/07/13/14/...). - Custom prefix expressions are evaluated:
!{timestamp:<pattern>}(JavaDateTimeFormatterpattern; all instances share the same instant) and!{firehose:random-string}(a fresh 11-character alphanumeric string per instance). When the prefix contains any expression, nothing is appended to it. CustomTimeZoneis honored for all timestamps; absent or invalid time zones fall back to UTC.
Known deviations from AWS: timestamps are evaluated at flush time instead of the oldest buffered record's arrival time; expressions AWS would reject at create time (unknown namespaces, !{partitionKeyFromQuery:...}/!{partitionKeyFromLambda:...} dynamic partitioning keys, invalid patterns) are kept literally in the key; delivered content is never compressed, so no compression extension is ever added.
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_FIREHOSE_ENABLED |
true |
Enable or disable the service |
Example
export AWS_ENDPOINT_URL=http://localhost:4566
# Create a stream
aws firehose create-delivery-stream --delivery-stream-name my-stream --endpoint-url $AWS_ENDPOINT_URL
# Put a record
aws firehose put-record \
--delivery-stream-name my-stream \
--record '{"Data": "{\"id\": 1, \"amount\": 10.5}"}' \
--endpoint-url $AWS_ENDPOINT_URL