Skip to content

Commit bad6c40

Browse files
committed
We don't need WasiView, only its table
Signed-off-by: itowlson <[email protected]>
1 parent e4f2f1b commit bad6c40

File tree

2 files changed

+6
-30
lines changed

2 files changed

+6
-30
lines changed

crates/factor-blobstore/src/host.rs

+5-21
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::{collections::HashSet, sync::Arc};
77
use tokio::io::{ReadHalf, SimplexStream, WriteHalf};
88
use tokio::sync::mpsc;
99
use tokio::sync::RwLock;
10-
use wasmtime_wasi::WasiView;
1110

1211
pub use bs::types::Error;
1312

@@ -127,33 +126,18 @@ pub trait Finishable: Send + Sync {
127126
pub struct BlobStoreDispatch<'a> {
128127
allowed_containers: HashSet<String>,
129128
manager: Arc<dyn ContainerManager>,
130-
wasi: wasmtime_wasi::WasiImpl<WasiImplInner<'a>>,
129+
wasi_resources: &'a mut ResourceTable,
131130
containers: Arc<RwLock<Table<Arc<dyn Container>>>>,
132131
incoming_values: Arc<RwLock<Table<Box<dyn IncomingData>>>>,
133132
outgoing_values: Arc<RwLock<Table<OutgoingValue>>>,
134133
object_names: Arc<RwLock<Table<Box<dyn ObjectNames>>>>,
135134
}
136135

137-
pub struct WasiImplInner<'a> {
138-
pub ctx: &'a mut wasmtime_wasi::WasiCtx,
139-
pub table: &'a mut ResourceTable,
140-
}
141-
142-
impl wasmtime_wasi::WasiView for WasiImplInner<'_> {
143-
fn ctx(&mut self) -> &mut wasmtime_wasi::WasiCtx {
144-
self.ctx
145-
}
146-
147-
fn table(&mut self) -> &mut ResourceTable {
148-
self.table
149-
}
150-
}
151-
152136
impl<'a> BlobStoreDispatch<'a> {
153137
pub(crate) fn new(
154138
allowed_containers: HashSet<String>,
155139
manager: Arc<dyn ContainerManager>,
156-
wasi: wasmtime_wasi::WasiImpl<WasiImplInner<'a>>,
140+
wasi_resources: &'a mut ResourceTable,
157141
containers: Arc<RwLock<Table<Arc<dyn Container>>>>,
158142
incoming_values: Arc<RwLock<Table<Box<dyn IncomingData>>>>,
159143
outgoing_values: Arc<RwLock<Table<OutgoingValue>>>,
@@ -162,7 +146,7 @@ impl<'a> BlobStoreDispatch<'a> {
162146
Self {
163147
allowed_containers,
164148
manager,
165-
wasi,
149+
wasi_resources,
166150
containers,
167151
incoming_values,
168152
outgoing_values,
@@ -275,7 +259,7 @@ impl bs::types::HostIncomingValue for BlobStoreDispatch<'_> {
275259
let mut incoming = self.take_incoming_value(self_).await?;
276260
let async_body = incoming.as_mut().consume_async();
277261
let host_stm: Box<dyn wasmtime_wasi::HostInputStream> = Box::new(async_body);
278-
let resource = self.wasi.table().push(host_stm).unwrap();
262+
let resource = self.wasi_resources.push(host_stm).unwrap();
279263
Ok(resource)
280264
}
281265

@@ -316,7 +300,7 @@ impl bs::types::HostOutgoingValue for BlobStoreDispatch<'_> {
316300
let stm = outgoing.write_stream()?;
317301

318302
let host_stm: Box<dyn wasmtime_wasi::HostOutputStream> = Box::new(stm);
319-
let resource = self.wasi.table().push(host_stm).unwrap();
303+
let resource = self.wasi_resources.push(host_stm).unwrap();
320304

321305
Ok(Ok(resource))
322306
}

crates/factor-blobstore/src/lib.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,10 @@ impl Factor for BlobStoreFactor {
5555
let get_data_with_table = ctx.get_data_with_table_fn();
5656
let closure = type_annotate(move |data| {
5757
let (state, table) = get_data_with_table(data);
58-
let wasi = wasmtime_wasi::WasiImpl(host::WasiImplInner {
59-
ctx: &mut state.ctx,
60-
table,
61-
});
6258
BlobStoreDispatch::new(
6359
state.allowed_containers.clone(),
6460
state.store_manager.clone(),
65-
wasi,
61+
table,
6662
state.containers.clone(),
6763
state.incoming_values.clone(),
6864
state.outgoing_values.clone(),
@@ -116,8 +112,6 @@ impl Factor for BlobStoreFactor {
116112
&self,
117113
ctx: PrepareContext<T, Self>,
118114
) -> anyhow::Result<InstanceBuilder> {
119-
let mut wasi_ctx = wasmtime_wasi::WasiCtxBuilder::new();
120-
121115
let app_state = ctx.app_state();
122116
let allowed_containers = app_state
123117
.component_allowed_containers
@@ -128,7 +122,6 @@ impl Factor for BlobStoreFactor {
128122
Ok(InstanceBuilder {
129123
store_manager: app_state.container_manager.clone(),
130124
allowed_containers,
131-
ctx: wasi_ctx.build(),
132125
containers: Arc::new(RwLock::new(Table::new(capacity))),
133126
incoming_values: Arc::new(RwLock::new(Table::new(capacity))),
134127
object_names: Arc::new(RwLock::new(Table::new(capacity))),
@@ -175,7 +168,6 @@ pub struct InstanceBuilder {
175168
store_manager: Arc<DelegatingContainerManager>,
176169
/// The allowed stores for this component instance.
177170
allowed_containers: HashSet<String>,
178-
ctx: wasmtime_wasi::WasiCtx,
179171
containers: Arc<RwLock<Table<Arc<dyn Container>>>>,
180172
incoming_values: Arc<RwLock<Table<Box<dyn IncomingData>>>>,
181173
outgoing_values: Arc<RwLock<Table<host::OutgoingValue>>>,

0 commit comments

Comments
 (0)