Initial DB implementation

This commit is contained in:
Gregory Schier
2026-03-08 14:39:00 -07:00
parent a5433fbc74
commit 7382287bef
9 changed files with 316 additions and 23 deletions

View File

@@ -82,11 +82,18 @@ pub enum RequestState {
pub struct ProxyHandle {
shutdown_tx: Option<tokio::sync::oneshot::Sender<()>>,
thread_handle: Option<std::thread::JoinHandle<()>>,
pub event_rx: std_mpsc::Receiver<ProxyEvent>,
event_rx: Option<std_mpsc::Receiver<ProxyEvent>>,
pub port: u16,
pub ca_pem: String,
}
impl ProxyHandle {
/// Take the event receiver. Can only be called once — returns `None` after the first call.
pub fn take_event_rx(&mut self) -> Option<std_mpsc::Receiver<ProxyEvent>> {
self.event_rx.take()
}
}
impl Drop for ProxyHandle {
fn drop(&mut self) {
if let Some(tx) = self.shutdown_tx.take() {
@@ -158,7 +165,7 @@ pub fn start_proxy(port: u16) -> Result<ProxyHandle, String> {
Ok(Ok(bound_port)) => Ok(ProxyHandle {
shutdown_tx: Some(shutdown_tx),
thread_handle: Some(thread_handle),
event_rx,
event_rx: Some(event_rx),
port: bound_port,
ca_pem,
}),