@@ -29,7 +29,7 @@ pub struct UserWorkerOptions {
2929
3030pub struct MainWorkerOptions {
3131 pub service_path : PathBuf ,
32- pub worker_pool_tx : mpsc:: UnboundedSender < WorkerPoolMsg > ,
32+ pub user_worker_msgs_tx : mpsc:: UnboundedSender < UserWorkerMsgs > ,
3333 pub no_module_cache : bool ,
3434 pub import_map_path : Option < String > ,
3535}
@@ -39,7 +39,7 @@ impl WorkerContext {
3939 let service_path = options. service_path ;
4040 let no_module_cache = options. no_module_cache ;
4141 let import_map_path = options. import_map_path ;
42- let worker_pool_tx = options. worker_pool_tx ;
42+ let user_worker_msgs_tx = options. user_worker_msgs_tx ;
4343
4444 // create a unix socket pair
4545 let ( sender_stream, recv_stream) = UnixStream :: pair ( ) ?;
@@ -49,7 +49,7 @@ impl WorkerContext {
4949 service_path. clone ( ) ,
5050 no_module_cache,
5151 import_map_path,
52- worker_pool_tx . clone ( ) ,
52+ user_worker_msgs_tx . clone ( ) ,
5353 ) ?;
5454
5555 // start the worker
@@ -145,9 +145,9 @@ pub struct CreateUserWorkerResult {
145145}
146146
147147#[ derive( Debug ) ]
148- pub enum WorkerPoolMsg {
149- CreateUserWorker ( UserWorkerOptions , oneshot:: Sender < CreateUserWorkerResult > ) ,
150- SendRequestToWorker ( String , Request < Body > , oneshot:: Sender < Response < Body > > ) ,
148+ pub enum UserWorkerMsgs {
149+ Create ( UserWorkerOptions , oneshot:: Sender < CreateUserWorkerResult > ) ,
150+ SendRequest ( String , Request < Body > , oneshot:: Sender < Response < Body > > ) ,
151151}
152152
153153pub struct WorkerPool {
@@ -160,14 +160,15 @@ impl WorkerPool {
160160 import_map_path : Option < String > ,
161161 no_module_cache : bool ,
162162 ) -> Result < Self , Error > {
163- let ( worker_pool_tx, mut worker_pool_rx) = mpsc:: unbounded_channel :: < WorkerPoolMsg > ( ) ;
163+ let ( user_worker_msgs_tx, mut user_worker_msgs_rx) =
164+ mpsc:: unbounded_channel :: < UserWorkerMsgs > ( ) ;
164165
165166 let main_path = Path :: new ( & main_path) ;
166167 let main_worker_ctx = WorkerContext :: new_main_worker ( MainWorkerOptions {
167168 service_path : main_path. to_path_buf ( ) ,
168169 import_map_path,
169170 no_module_cache,
170- worker_pool_tx ,
171+ user_worker_msgs_tx ,
171172 } )
172173 . await ?;
173174 let main_worker = Arc :: new ( RwLock :: new ( main_worker_ctx) ) ;
@@ -176,9 +177,9 @@ impl WorkerPool {
176177 let mut user_workers: HashMap < String , Arc < RwLock < WorkerContext > > > = HashMap :: new ( ) ;
177178
178179 loop {
179- match worker_pool_rx . recv ( ) . await {
180+ match user_worker_msgs_rx . recv ( ) . await {
180181 None => break ,
181- Some ( WorkerPoolMsg :: CreateUserWorker ( worker_options, tx) ) => {
182+ Some ( UserWorkerMsgs :: Create ( worker_options, tx) ) => {
182183 let key = worker_options. service_path . display ( ) . to_string ( ) ;
183184 if !user_workers. contains_key ( & key) {
184185 // TODO: handle errors
@@ -191,7 +192,7 @@ impl WorkerPool {
191192
192193 tx. send ( CreateUserWorkerResult { key } ) ;
193194 }
194- Some ( WorkerPoolMsg :: SendRequestToWorker ( key, req, tx) ) => {
195+ Some ( UserWorkerMsgs :: SendRequest ( key, req, tx) ) => {
195196 // TODO: handle errors
196197 let worker = user_workers. get ( & key) . unwrap ( ) ;
197198 let mut worker = worker. write ( ) . await ;
0 commit comments