feat: add streaming I/O pipeline to daemon#15
Merged
Conversation
Refactor the daemon from hardcoded stdin/stdout I/O to a pluggable streaming architecture with EventSource trait and Sink enum dispatch. Sources: StdinSource, HTTP POST /api/v1/events, NATS JetStream consumer Sinks: StdoutSink, FileSink (NDJSON append), NatsSink (JetStream publish) Fan-out: multiple --output flags via Sink::FanOut(Vec<Sink>) Pipeline: source -> mpsc channel -> engine task -> mpsc channel -> sink task Key changes: - process_line() returns ProcessResult instead of writing to stdout - New streaming module with EventSource trait and Sink enum - --input flag (stdin, http, nats://) and --output flag (stdout, file://, nats://) - daemon-nats feature flag with async-nats + tokio-stream dependencies - 4 integration tests (stdin->stdout, file output, fan-out, no-match) - README updated with streaming usage examples
rustls-webpki 0.102.x CRL matching bug is a transitive dependency of async-nats 0.46.0 (latest). Cannot upgrade until async-nats releases a version that depends on rustls-webpki 0.103.x.
Wrap synchronous sinks in block_in_place to avoid blocking the Tokio runtime, skip empty ProcessResults before sending to sink channel, use batch inc_by for metrics, derive NATS names from subject instead of hardcoding, and store Subject as Arc<str> to avoid per-publish String clones.
The sink task was spawned but never awaited, causing the process to exit before the sink finished writing buffered results to file. This fixes a race condition in the daemon_streaming_file_output CI test.
6a7b4d1 to
a32edf9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EventSourcetrait andSinkenum dispatch--input(stdin, http, nats://) and--output(stdout, file://, nats://) CLI flags with fan-out supportdaemon-natsfeature flag for NATS JetStream source/sink behindasync-natsPipeline
Test plan
cargo clippy --all-features -- -D warningsclean--features daemonand--all-features