Skip to content

Commit 28c5504

Browse files
committed
refactor: allow handle
1 parent 69b8d0f commit 28c5504

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

crates/core/src/logstore/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub fn logstore_with(
134134
.map_err(|_| DeltaTableError::InvalidTableLocation(location.clone().into()))?;
135135

136136
let store = if let Some(io_runtime) = io_runtime {
137-
Arc::new(DeltaIOStorageBackend::new(store, io_runtime.get_rt())) as ObjectStoreRef
137+
Arc::new(DeltaIOStorageBackend::new(store, io_runtime.get_handle())) as ObjectStoreRef
138138
} else {
139139
store
140140
};

crates/core/src/storage/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use object_store::memory::InMemory;
1414
use object_store::prefix::PrefixStore;
1515
use object_store::{GetOptions, PutOptions, PutPayload, PutResult};
1616
use serde::{Deserialize, Serialize};
17-
use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
17+
use tokio::runtime::{Builder as RuntimeBuilder, Handle, Runtime};
1818
use url::Url;
1919

2020
use bytes::Bytes;
@@ -39,7 +39,7 @@ lazy_static! {
3939
}
4040

4141
/// Creates static IO Runtime with optional configuration
42-
fn io_rt(config: Option<&RuntimeConfig>) -> &'static Runtime {
42+
fn io_rt(config: Option<&RuntimeConfig>) -> &Runtime {
4343
static IO_RT: OnceLock<Runtime> = OnceLock::new();
4444
IO_RT.get_or_init(|| {
4545
let rt = match config {
@@ -88,36 +88,37 @@ pub struct RuntimeConfig {
8888
#[derive(Debug, Clone)]
8989
pub enum IORuntime {
9090
/// Tokio RT handle
91-
RT(&'static Runtime),
91+
RT(Handle),
9292
/// Configuration for tokio runtime
9393
Config(RuntimeConfig),
9494
}
9595

9696
impl Default for IORuntime {
9797
fn default() -> Self {
98-
IORuntime::RT(io_rt(None))
98+
IORuntime::RT(io_rt(None).handle().clone())
9999
}
100100
}
101101

102102
impl IORuntime {
103103
/// Retrieves the Tokio runtime for IO bound operations
104-
pub fn get_rt(&self) -> &'static Runtime {
104+
pub fn get_handle(&self) -> Handle {
105105
match self {
106-
IORuntime::RT(handle) => *handle,
107-
IORuntime::Config(config) => io_rt(Some(config)),
106+
IORuntime::RT(handle) => handle,
107+
IORuntime::Config(config) => io_rt(Some(config)).handle(),
108108
}
109+
.clone()
109110
}
110111
}
111112

112113
/// Wraps any object store and runs IO in it's own runtime [EXPERIMENTAL]
113114
pub struct DeltaIOStorageBackend {
114115
inner: ObjectStoreRef,
115-
rt_handle: &'static Runtime,
116+
rt_handle: Handle,
116117
}
117118

118119
impl DeltaIOStorageBackend {
119120
/// create wrapped object store which spawns tasks in own runtime
120-
pub fn new(storage: ObjectStoreRef, rt_handle: &'static Runtime) -> Self {
121+
pub fn new(storage: ObjectStoreRef, rt_handle: Handle) -> Self {
121122
Self {
122123
inner: storage,
123124
rt_handle,

0 commit comments

Comments
 (0)