Shared dict state file#915
Merged
Merged
Conversation
This is a preparatory patch for upcoming changes to unify common code for njs and QuickJS engines.
A new optional state parameter is added for js_shared_dict_zone directive. state parameter specifies a file that keeps the current state of the shared dict in the JSON format and makes it persistent across nginx restarts. This closes nginx#709 feature request on Github.
3c4a405 to
75371c1
Compare
There was a problem hiding this comment.
Pull Request Overview
Adds persistent state file support for js_shared_dict_zone by introducing a new optional state parameter and ensuring shared dictionary data is serialized to and from a JSON file across NGINX restarts.
- Introduces a conditional guard in
njs_chb_destroyto avoid calling a null free callback. - Adds
ngx_js_dict_init_workerinitialization in both HTTP and stream modules, alongside refactoring periodic init into separate functions. - Includes new tests (
*_state.t) to verify state file persistence and removes obsoleteengineexports from existing NJS test files.
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/njs_chb.c | Guarded the free callback in chain destruction when chain->free is null |
| nginx/ngx_js_shared_dict.h | Declared ngx_js_dict_init_worker for shared dict worker init |
| nginx/ngx_js.h | Moved fetch/shared_dict includes and added NGX_CHB_CTX_INIT macro |
| nginx/ngx_stream_js_module.c | Refactored worker init to call periodic and dict init separately |
| nginx/ngx_http_js_module.c | Mirrored stream changes for HTTP module worker init |
| nginx/t/stream_js_shared_dict_state.t | New stream tests for shared dict state file persistence |
| nginx/t/js_shared_dict_state.t | New HTTP tests for shared dict state file persistence |
| nginx/t/stream_js_shared_dict.t | Removed unused engine exports |
| nginx/t/stream_js_periodic_fetch.t | Removed unused engine exports |
| nginx/t/stream_js_fetch_init.t | Removed unused engine exports |
| nginx/t/stream_js_fetch_https.t | Removed unused engine exports |
| nginx/t/stream_js_fetch.t | Removed unused engine exports |
| nginx/t/js_shared_dict.t | Removed unused engine exports |
| nginx/t/js_periodic_fetch.t | Removed unused engine exports |
| nginx/t/js_fetch_verify.t | Removed unused engine exports |
| nginx/t/js_fetch_timeout.t | Removed unused engine exports |
| nginx/t/js_fetch_resolver.t | Removed unused engine exports |
| nginx/t/js_fetch_objects.t | Removed unused engine exports |
| nginx/t/js_fetch_https.t | Removed unused engine exports |
| nginx/t/js_fetch.t | Removed unused engine exports |
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.
Modules: added state file for a shared dictionary.
A new optional state parameter is added for js_shared_dict_zone
directive. state parameter specifies a file that keeps the current state
of the shared dict in the JSON format and makes it persistent
across nginx restarts.
This closes #709 feature request on Github.