Skip to content

usnm-ingest: sink.rs in one module per concern - #1034

Merged
tgoodyear merged 2 commits into
mainfrom
ingest/sink-modules
Oct 23, 2026
Merged

tgoodyear merged 2 commits into
mainfrom
ingest/sink-modules

Conversation

@tgoodyear

Copy link
Copy Markdown
Owner

crates/usnm-ingest/src/sink.rs was 3,791 lines holding three concerns with almost no coupling: rewriting the index template, running the writer child process, and the Quickwit ingest client. Each is now its own file with its tests beside it; the parent keeps the sink trait, the title fields, the stats, the JSONL sink and every public path through pub use. Code moved, not changed.

File Lines Holds
sink.rs 342 IndexSink, TitleFieldsByLccn and add_title_fields, SinkStats, JsonlSink, INDEX_TEMPLATE (its include_str! path unchanged), INGEST_QUEUE_MEMORY, the mod and pub use lines
sink/template.rs 652 WriterTuning, Decades, MainLayout, main_template, page_language_fields, split_target, text_fields, the TEMPLATE_* constants; 6 tests
sink/node.rs 1,318 Tail, strip_ansi, forward, writer_log_filter, QuickwitNode, describe_exit, prepare_local_wal, supervise, WriterProcess, Run, the throughput, split-store, WAL and merge constants; 18 tests
sink/quickwit.rs 1,544 IngestApi, title_fields_of, QuickwitSink, Poster, LineSender, impl IndexSink for QuickwitSink, the restart glue; 18 tests

The four QuickwitNode fields the sink's watching reads are pub(super). forward was private and stays private to sink::node; the one doc comment in merges.rs that named it as sink::forward now names the new path. docs/design/05-search-and-storage.md cites text_fields, split_target and Decades::Partitioned at sink/template.rs now; the Bicep and Quickwit config comments that cite the file generically stay true.

Checks

  • cargo test -p usnm-ingest --lib --locked: 302 passed before and after; the 42 sink tests have the same function names (18 node, 18 quickwit, 6 template).
  • cargo fmt --all --check clean; cargo clippy -p usnm-ingest --lib --tests --locked -- -D warnings clean; scripts/ci/test_changes.py passes (it resolves the include_str!); prettier clean on the doc.
  • The old file's 3,600 non-blank lines compared with the new files: only the module docs, imports, mod/pub use lines, the four visibility changes and the test-module wrappers differ.

Generated by Claude Code

Copilot AI balanced review requested due to automatic review settings October 23, 2026 13:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

No open issues 🎉

What changed in this PR

Refactors usnm-ingest’s sink implementation by splitting the former oversized sink.rs into separate modules for index template generation, writer node process supervision, and the Quickwit ingest client, while preserving existing public APIs via pub use.

Changes:

  • Split crates/usnm-ingest/src/sink.rs into sink/template.rs, sink/node.rs, and sink/quickwit.rs
  • Updated design documentation and an internal doc reference to reflect new module paths
  • Preserved existing test coverage by moving tests alongside their corresponding modules
File Description
docs/​design/​05-search-and-storage.md Updates references to text_fields, split_target, and Decades::Partitioned to point at sink/template.rs
crates/​usnm-ingest/​src/​sink.rs Converts monolithic sink implementation into a small module root with mod + pub use re-exports
crates/​usnm-ingest/​src/​sink/​template.rs New module containing index template rewriting logic and related tests
crates/​usnm-ingest/​src/​sink/​node.rs New module containing writer node process management/supervision and related tests
crates/​usnm-ingest/​src/​sink/​quickwit.rs New module containing Quickwit ingest client logic and related tests
crates/​usnm-ingest/​src/​merges.rs Updates a doc reference to forward’s new module path

Review effort: Lite

sink.rs (3,791 lines) keeps the sink trait, the title fields, the stats
and the JSONL sink; the index template rewriting, the writer child process
and the Quickwit ingest client move to sink/template.rs, node.rs and
quickwit.rs, each with its tests. Every public path is re-exported. Code
moved, not changed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UsspoBVGFP5Juo1rh6Wwqt
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UsspoBVGFP5Juo1rh6Wwqt
@tgoodyear
tgoodyear force-pushed the ingest/sink-modules branch from 0dcb739 to 7513831 Compare October 23, 2026 15:07
@tgoodyear
tgoodyear merged commit fc117a1 into main Oct 23, 2026
47 checks passed
@tgoodyear
tgoodyear deleted the ingest/sink-modules branch October 23, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants