feat(converter): add streaming generation for large configurations - #189
Conversation
- Remove forced runtime.GC() calls from XML parser (let Go manage GC) - Add context cancellation support to parser for timeout handling - Replace init() with sync.Once for global plugin registry initialization - Use errors.Join() instead of chained %w error wrapping in convert cmd - Sort map keys in report generation for deterministic output - Simplify combineValidationErrors to use only strings.Builder - Fix golangci-lint config conflict (gocyclo was both enabled/disabled) - Run go mod tidy to remove unused dependencies Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement Tier 1 streaming optimization for issue #143: - Add SectionWriter interface for io.Writer-based report generation - Add StreamingGenerator interface extending Generator - Implement WriteStandardReport and WriteComprehensiveReport methods - Add GenerateToWriter method to HybridGenerator - Add generateToWriter infrastructure in convert.go for future use - Preserve string-based API for HTML conversion workflows This enables memory-efficient streaming output for large configurations (1-5 MB production config.xml files) while maintaining compatibility with the existing string-based API for further processing needs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. 📝 WalkthroughSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThis PR implements streaming output generation for large OPNsense configurations to address memory efficiency concerns. It introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Parser as XML Parser
participant Generator as HybridGenerator
participant Writer as SectionWriter
participant Output as io.Writer
Client->>Parser: Parse(ctx, reader)
Parser->>Parser: Check ctx.Done()
Parser-->>Generator: OpnSenseDocument
Client->>Generator: GenerateToWriter(ctx, writer, doc, opts)
Generator->>Generator: Determine format (Markdown/JSON/YAML)
alt Markdown Format
Generator->>Writer: WriteStandardReport(writer, doc)
Writer->>Output: WriteHeader()
Writer->>Output: WriteTOC()
Writer->>Output: WriteSystemSection()
Writer->>Output: WriteNetworkSection()
Writer->>Output: WriteSecuritySection()
Writer->>Output: WriteServicesSection()
Writer->>Output: WriteFooter()
else JSON/YAML Format
Generator->>Output: Marshal and write directly
end
Output-->>Client: Streamed output (low memory)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…ocker snapshot, action pin - Go version matrix in ci.yml test job: [stable, oldstable] with fail-fast: false; matches Go upstream support policy (N and N-1). Mergify required checks updated to 6 expanded names. - CONTRIBUTING.md + README.md state the Go support policy explicitly. - codecov.yml: raise project + patch targets from 70%/60% to 80%/80% (current total is 86.1%); add ignore: for testdata/, dist/. Mergify merge_protections wired with codecov/project + codecov/patch gates. - Remove --skip=docker from goreleaser snapshot path in release.yml; GoReleaser --snapshot prevents registry pushes per docs; buildx already wired. Inline citation comment + updated snapshot summary to describe dockers_v2 platform-suffixed local tags. - action.yml default version: "latest" -> "v1.4.0"; description actively recommends SHA pinning. latest remains valid (not rejected). - README.md: sweep 3 GitHub Action examples from @main to @v1.4.0; drop stale "No release tags exist yet" comments; add new Pinning subsection (SHA pin recommended for production; tag pin acceptable; @main/@latest not recommended). - RELEASING.md checklist items for future releases: bump action.yml default tag, sweep README usage examples, update SHA-pin example. - SBOM job de-dup: ci.yml SBOM gated to push-to-main only; sbom.yml scheduled weekly and goreleaser release-time SBOMs unaffected. - benchmarks.yml: replace ad-hoc `go install benchstat@latest` with `mise exec -- benchstat` (mise.toml pins benchstat). Todos resolved: #119, #167, #168, #171, #172, #189. Notes: - Mergify `dependabot-workflows` queue still only requires `Lint` (workflow-only changes, intentional). Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
…ocker snapshot, action pin - Go version matrix in ci.yml test job: [stable, oldstable] with fail-fast: false; matches Go upstream support policy (N and N-1). Mergify required checks updated to 6 expanded names. - CONTRIBUTING.md + README.md state the Go support policy explicitly. - codecov.yml: raise project + patch targets from 70%/60% to 80%/80% (current total is 86.1%); add ignore: for testdata/, dist/. Mergify merge_protections wired with codecov/project + codecov/patch gates. - Remove --skip=docker from goreleaser snapshot path in release.yml; GoReleaser --snapshot prevents registry pushes per docs; buildx already wired. Inline citation comment + updated snapshot summary to describe dockers_v2 platform-suffixed local tags. - action.yml default version: "latest" -> "v1.4.0"; description actively recommends SHA pinning. latest remains valid (not rejected). - README.md: sweep 3 GitHub Action examples from @main to @v1.4.0; drop stale "No release tags exist yet" comments; add new Pinning subsection (SHA pin recommended for production; tag pin acceptable; @main/@latest not recommended). - RELEASING.md checklist items for future releases: bump action.yml default tag, sweep README usage examples, update SHA-pin example. - SBOM job de-dup: ci.yml SBOM gated to push-to-main only; sbom.yml scheduled weekly and goreleaser release-time SBOMs unaffected. - benchmarks.yml: replace ad-hoc `go install benchstat@latest` with `mise exec -- benchstat` (mise.toml pins benchstat). Todos resolved: #119, #167, #168, #171, #172, #189. Notes: - Mergify `dependabot-workflows` queue still only requires `Lint` (workflow-only changes, intentional). Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Summary
Changes
Streaming Generation (issue #143)
SectionWriterinterface forio.Writer-based report generationStreamingGeneratorinterface extendingGeneratorwithGenerateToWriterWriteStandardReportandWriteComprehensiveReportmethodsCode Quality Improvements
init()withsync.Oncepattern for global registryerrors.Join()for proper error accumulationslices.Sorted(maps.Keys())for deterministic map iterationruntime.GC()callsTest plan
writer_test.go)just ci-checkpassesCloses #143
🤖 Generated with Claude Code