Skip to content

Conversation

@ncode
Copy link
Owner

@ncode ncode commented Jan 26, 2026

This pull request introduces significant improvements to the audit server's asynchronous processing and error handling for notifications and forwarding, as well as new tests for these features. The main changes include refactoring notification and forwarding to be handled asynchronously via a side queue, adding configuration options and metrics for this queue, improving UDP forwarder timeout handling, and updating tests to reflect the new async behavior.

Asynchronous Processing and Queue Management:

  • Introduced a sideQueue and background workers to handle notifications (messenger.Send) and forwarding (forwarder.Forward) asynchronously in AuditServer. This decouples these potentially slow operations from the main request processing path, improving throughput and reliability. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-214cde7b7434e7b07bb1f44bb1792ef3255bd9fba5b33b7dc41aa306d990908eR1-R47), [[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R135-R138), [[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7L148-R201))
  • Added configuration options for async queue size and timeout (async.queue_size, async.timeout) with sensible defaults, and exposed a metric (sideDrops) to track dropped tasks when the queue is full. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R228-R241), [[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R135-R138), [[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R317-R327))

Error Handling and Default Behavior:

  • Changed the server's behavior so that errors in notification or forwarding no longer cause the connection to close; only unmatched rules do. This is reflected in the tests and main logic. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7L148-R201), [[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L163-R180), [[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L698-R809), [[4]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L889-R1018))
  • Ensured that a default rule group is created if none are configured, improving robustness and simplifying configuration. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R250-R257), [[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R354-R447))

UDP Forwarder Improvements:

  • Added a per-write timeout for the UDP forwarder, making it more robust to network issues and configurable via the async timeout setting. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-a14c4239c1b85a957fd71e7038cf38822e97afc3d2edf4169414bc28d8b12248R18-R19), [[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-a14c4239c1b85a957fd71e7038cf38822e97afc3d2edf4169414bc28d8b12248R35-R49), [[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7L255-R287), [[4]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R303-R305))

Testing Enhancements:

  • Added new and updated existing tests to cover async queue behavior (including queue drops), async notification/forwarding, and default rule group creation. Introduced concurrency-safe test helpers. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R354-R447), [[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L698-R809), [[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L727-R838), [[4]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R920-R955), [[5]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L889-R1018))
  • Added benchmarks for React and rule evaluation to measure performance improvements from async processing. ([pkg/auditserver/bench_test.goR1-R43](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-4928cc6308985a8649cab17eed8ed131a67a8eae2b52cc12ab89f89715d18318R1-R43))

Miscellaneous:

  • Improved thread safety and test reliability with concurrency-safe buffers and counters in test helpers. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R63-R79), [[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R920-R955))

References:

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 87.35632% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.01%. Comparing base (d5e6e1a) to head (3367f5f).

Files with missing lines Patch % Lines
pkg/auditserver/server.go 83.01% 5 Missing and 4 partials ⚠️
pkg/forwarder/forwarder.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
- Coverage   88.88%   88.01%   -0.88%     
==========================================
  Files           8        9       +1     
  Lines         279      342      +63     
==========================================
+ Hits          248      301      +53     
- Misses         24       29       +5     
- Partials        7       12       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ncode ncode force-pushed the julinao/split_queues branch from 7387f7c to 23d1f5d Compare January 26, 2026 21:52
@ncode ncode force-pushed the julinao/split_queues branch from 23d1f5d to 6edcc38 Compare January 26, 2026 21:54
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.

2 participants