(config: &SessionQueueConfig)
| 2095 | } |
| 2096 | |
| 2097 | fn js_queue_config_to_rust(config: &SessionQueueConfig) -> napi::Result<RustSessionQueueConfig> { |
| 2098 | let mut c = if config.enable_all_features.unwrap_or(false) { |
| 2099 | RustSessionQueueConfig::default().with_lane_features() |
| 2100 | } else { |
| 2101 | RustSessionQueueConfig::default() |
| 2102 | }; |
| 2103 | if let Some(n) = config.query_concurrency { |
| 2104 | c.query_max_concurrency = n as usize; |
| 2105 | } |
| 2106 | if let Some(n) = config.execute_concurrency { |
| 2107 | c.execute_max_concurrency = n as usize; |
| 2108 | } |
| 2109 | if let Some(n) = config.generate_concurrency { |
| 2110 | c.generate_max_concurrency = n as usize; |
| 2111 | } |
| 2112 | if let Some(true) = config.enable_dlq { |
| 2113 | c = c.with_dlq(config.dlq_max_size.map(|n| n as usize)); |
| 2114 | } |
| 2115 | if let Some(true) = config.enable_metrics { |
| 2116 | c = c.with_metrics(); |
| 2117 | } |
| 2118 | if let Some(true) = config.enable_alerts { |
| 2119 | c = c.with_alerts(); |
| 2120 | } |
| 2121 | if let Some(ms) = config.timeout_ms { |
| 2122 | c = c.with_timeout(ms as u64); |
| 2123 | } |
| 2124 | if let Some(ref handlers) = config.lane_handlers { |
| 2125 | for (lane_str, handler) in handlers { |
| 2126 | let lane = parse_lane(lane_str)?; |
| 2127 | let mode = parse_handler_mode(&handler.mode)?; |
| 2128 | let lane_cfg = RustLaneHandlerConfig { |
| 2129 | mode, |
| 2130 | timeout_ms: handler.timeout_ms.map(|ms| ms as u64).unwrap_or(60_000), |
| 2131 | }; |
| 2132 | c.lane_handlers.insert(lane, lane_cfg); |
| 2133 | } |
| 2134 | } |
| 2135 | Ok(c) |
| 2136 | } |
| 2137 | |
| 2138 | fn parse_lane(lane: &str) -> napi::Result<RustSessionLane> { |
| 2139 | match lane.trim().to_ascii_lowercase().as_str() { |
no test coverage detected