Fix running without neon storage

This commit is contained in:
Heikki Linnakangas
2025-07-14 20:12:19 +03:00
parent 276758e868
commit dd53484c17
3 changed files with 19 additions and 10 deletions

View File

@@ -10,11 +10,11 @@ pub struct CommunicatorWorkerProcessStruct {
}
pub(super) async fn init(
tenant_id: String,
timeline_id: String,
tenant_id: Option<&str>,
timeline_id: Option<&str>,
) -> CommunicatorWorkerProcessStruct {
let _tenant_id = TenantId::from_str(&tenant_id).expect("invalid tenant ID");
let _timeline_id = TimelineId::from_str(&timeline_id).expect("invalid timeline ID");
let _tenant_id = tenant_id.map(|s| TenantId::from_str(s).expect("invalid tenant ID"));
let _timeline_id = timeline_id.map(|s| TimelineId::from_str(s).expect("invalid timeline ID"));
CommunicatorWorkerProcessStruct {
// metrics

View File

@@ -15,8 +15,16 @@ pub extern "C" fn communicator_worker_process_launch(
timeline_id: *const c_char,
) -> &'static CommunicatorWorkerProcessStruct {
// Convert the arguments into more convenient Rust types
let tenant_id = unsafe { CStr::from_ptr(tenant_id) }.to_str().unwrap();
let timeline_id = unsafe { CStr::from_ptr(timeline_id) }.to_str().unwrap();
let tenant_id = if tenant_id.is_null() {
None
} else {
Some(unsafe { CStr::from_ptr(tenant_id) }.to_str().unwrap())
};
let timeline_id = if timeline_id.is_null() {
None
} else {
Some(unsafe { CStr::from_ptr(timeline_id) }.to_str().unwrap())
};
let runtime = tokio::runtime::Builder::new_multi_thread()
.enable_all()
@@ -25,8 +33,8 @@ pub extern "C" fn communicator_worker_process_launch(
.unwrap();
let worker_struct = runtime.block_on(main_loop::init(
tenant_id.to_string(),
timeline_id.to_string(),
tenant_id,
timeline_id,
));
let worker_struct = Box::leak(Box::new(worker_struct));

View File

@@ -94,8 +94,9 @@ communicator_new_bgworker_main(Datum main_arg)
logging = configure_logging();
proc_handle = communicator_worker_process_launch(
neon_tenant,
neon_timeline);
neon_tenant[0] == '\0' ? NULL : neon_tenant,
neon_timeline[0] == '\0' ? NULL : neon_timeline
);
/* proc_handle is not currently used, but will be in the future */
(void) proc_handle;