Skip to content

add ffi and rust wrapper for domainmap#48336

Merged
jkarneges merged 1 commit intomainfrom
jkarneges/domainmap-ffi
Apr 29, 2026
Merged

add ffi and rust wrapper for domainmap#48336
jkarneges merged 1 commit intomainfrom
jkarneges/domainmap-ffi

Conversation

@jkarneges
Copy link
Copy Markdown
Member

@jkarneges jkarneges commented Apr 29, 2026

This makes DomainMap available to Rust, without actually using it anywhere yet. For now the API is minimal, only allowing looking up the log_level of a route by ID.

Normally, DomainMap emits a signal whenever the routes file changes, but this only makes sense if there is a C++-managed event loop in the thread that instantiated it otherwise the queued signals may pile up. To make DomainMap usable in Rust apps that won't have such an event loop, this PR makes it so signals are only emitted when one is detected. An assertion is also added to DeferCall to prevent doing the wrong thing by accident.

Manually tested with the following local change:

--- a/src/connmgr/mod.rs
+++ b/src/connmgr/mod.rs
@@ -473,6 +473,10 @@ impl App {
 pub fn run(config: &Config) -> Result<(), Box<dyn Error>> {
     debug!("starting...");
 
+    let domainmap = crate::proxy::domainmap::DomainMap::new("routes");
+    let params = domainmap.lookup("example").unwrap();
+    info!("example log_level={}", params.log_level);
+
     {
         let a = match App::new(config) {
             Ok(a) => a,

Results:

% cat routes 
* test
example.com,id=example,log_level=1 test

% bin/pushpin-connmgr --log-level 3         
[DEBUG] 2026-04-29 11:24:51.670 [pushpin::connmgr] starting...
[DEBUG] 2026-04-29 11:24:51.670 domainmap thread started
[DEBUG] 2026-04-29 11:24:51.672 routes by domain:
[DEBUG] 2026-04-29 11:24:51.672   (default): test
[DEBUG] 2026-04-29 11:24:51.672   example.com: test
[INFO] 2026-04-29 11:24:51.672 routes loaded with 2 entries
[INFO] 2026-04-29 11:24:51.672 example log_level=1
...
[INFO] 2026-04-29 11:24:54.140 routes file changed, reloading
[DEBUG] 2026-04-29 11:24:55.133 routes by domain:
[DEBUG] 2026-04-29 11:24:55.133   (default): test
[DEBUG] 2026-04-29 11:24:55.133   example.com: test
[INFO] 2026-04-29 11:24:55.133 routes loaded with 2 entries
...
^C[INFO] 2026-04-29 11:25:00.778 stopping...
...
[DEBUG] 2026-04-29 11:25:00.784 [pushpin::connmgr] stopped
[DEBUG] 2026-04-29 11:25:00.785 domainmap thread stopped

@jkarneges jkarneges requested a review from a team April 29, 2026 20:02
@jkarneges jkarneges merged commit a78d17c into main Apr 29, 2026
19 checks passed
@jkarneges jkarneges deleted the jkarneges/domainmap-ffi branch April 29, 2026 20:19
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