Skip to content

feat: add core main-conf access#272

Open
ryan-surname-p wants to merge 3 commits intonginx:mainfrom
ryan-surname-p:rnpridgeon/core_conf
Open

feat: add core main-conf access#272
ryan-surname-p wants to merge 3 commits intonginx:mainfrom
ryan-surname-p:rnpridgeon/core_conf

Conversation

@ryan-surname-p
Copy link
Copy Markdown

Add core main-conf wrapper for accessing top-level core main
configuration in ngx-rust.

This introduces:

  • CoreModuleConfExt for ngx_conf_t and ngx_cycle_t
  • core_main_conf / core_main_conf_mut typed helpers
  • NgxCoreModule convenience accessors for ngx_core_conf_t

The new API mirrors the existing HTTP config helper style while
centralizing the unsafe conf_ctx slot traversal in one place.

Why:

Modules that need core process configuration currently have to manually
walk cycle->conf_ctx, index with ngx_core_module.index, and cast to
ngx_core_conf_t. That is repetitive, easy to get wrong, and noisy in
reviews.

The immediate use case is the nginx-wasm issue where module
code needs access to core config such as the env state.

Ref: https://github.com/nginx/nginx-wasm/issues/37

@ryan-surname-p ryan-surname-p changed the title Add core main-conf access helpers for ngx_core_module feat: add core main-conf access Apr 3, 2026
@ensh63
Copy link
Copy Markdown
Contributor

ensh63 commented Apr 3, 2026

This is a really useful addition. But I'd like to suggest to make one step further and implement configuration trait for arbitrary core module similar to HttpModuleMainConf with associated type for config data and functions to get it. Current approach defines interface for main core module only which may not be enough. It does not allow to define config interface for new core modules, and it does not include definitions for module-specific config data types.

@ryan-surname-p
Copy link
Copy Markdown
Author

Sure thing @ensh63 , I'll follow up next week with CoreModuleConf

@ryan-surname-p
Copy link
Copy Markdown
Author

Updated with CoreModuleMainConf, made NgxCoreModule a concrete implementation of it.

Cleaned out the lingering public accessors from testing.

Comment thread src/core/conf.rs
}

/// Auxiliary structure to access `ngx_core_module` configuration.
pub struct NgxCoreModule;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may expect a special trait for core module, similar to HttpModule trait. To make this PR minimal, I'd suggest to include only module() method to it for now. In future this will allow to add all other necessary components to this trait.

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