@@ -14,7 +14,7 @@ use object_store::memory::InMemory;
14
14
use object_store:: prefix:: PrefixStore ;
15
15
use object_store:: { GetOptions , PutOptions , PutPayload , PutResult } ;
16
16
use serde:: { Deserialize , Serialize } ;
17
- use tokio:: runtime:: { Builder as RuntimeBuilder , Runtime } ;
17
+ use tokio:: runtime:: { Builder as RuntimeBuilder , Handle , Runtime } ;
18
18
use url:: Url ;
19
19
20
20
use bytes:: Bytes ;
@@ -39,7 +39,7 @@ lazy_static! {
39
39
}
40
40
41
41
/// Creates static IO Runtime with optional configuration
42
- fn io_rt ( config : Option < & RuntimeConfig > ) -> & ' static Runtime {
42
+ fn io_rt ( config : Option < & RuntimeConfig > ) -> & Runtime {
43
43
static IO_RT : OnceLock < Runtime > = OnceLock :: new ( ) ;
44
44
IO_RT . get_or_init ( || {
45
45
let rt = match config {
@@ -88,36 +88,37 @@ pub struct RuntimeConfig {
88
88
#[ derive( Debug , Clone ) ]
89
89
pub enum IORuntime {
90
90
/// Tokio RT handle
91
- RT ( & ' static Runtime ) ,
91
+ RT ( Handle ) ,
92
92
/// Configuration for tokio runtime
93
93
Config ( RuntimeConfig ) ,
94
94
}
95
95
96
96
impl Default for IORuntime {
97
97
fn default ( ) -> Self {
98
- IORuntime :: RT ( io_rt ( None ) )
98
+ IORuntime :: RT ( io_rt ( None ) . handle ( ) . clone ( ) )
99
99
}
100
100
}
101
101
102
102
impl IORuntime {
103
103
/// Retrieves the Tokio runtime for IO bound operations
104
- pub fn get_rt ( & self ) -> & ' static Runtime {
104
+ pub fn get_handle ( & self ) -> Handle {
105
105
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 ( ) ,
108
108
}
109
+ . clone ( )
109
110
}
110
111
}
111
112
112
113
/// Wraps any object store and runs IO in it's own runtime [EXPERIMENTAL]
113
114
pub struct DeltaIOStorageBackend {
114
115
inner : ObjectStoreRef ,
115
- rt_handle : & ' static Runtime ,
116
+ rt_handle : Handle ,
116
117
}
117
118
118
119
impl DeltaIOStorageBackend {
119
120
/// 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 {
121
122
Self {
122
123
inner : storage,
123
124
rt_handle,
0 commit comments