-
Notifications
You must be signed in to change notification settings - Fork 184
Shared dict state file #915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_destroy
to avoid calling a null free callback. - Adds
ngx_js_dict_init_worker
initialization 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 obsoleteengine
exports 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 |
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.