Implement automatic JavaScript file reloading #91
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.
Closes #88
Overview
Implements automatic reloading of JavaScript rules when using
--js-file. The file is checked for modifications on each request, and if changed, the code is validated and atomically reloaded.Implementation Approach
On-demand mtime checking (not background polling or inotify):
evaluate()methodKey Design Decisions:
ArcSwap<(String, Option<SystemTime>)>for hot path performanceCode Refactoring
The
evaluate()method was decomposed from 98 lines into focused helper methods:check_and_reload_file()- File monitoring and reload logic (48 lines)load_js_code()- Lock-free code loading (4 lines)execute_js_blocking()- V8 execution in blocking task (32 lines)build_evaluation_result()- Result construction (15 lines)Also added comprehensive module and struct documentation.
Testing
tests/js_file_reload.rsDocumentation
Updated:
--js-fileflag documentationDependencies
Added
arc-swap = "1.7"to Cargo.toml for lock-free atomic updates.