@@ -112,7 +112,7 @@ enum ConnectionError {
112112
113113async fn handle_connection < S > (
114114 ws_conn : WebSocket ,
115- adapter : Arc < S > ,
115+ state : Arc < S > ,
116116 notify_price_tx_buffer : usize ,
117117 notify_price_sched_tx_buffer : usize ,
118118 logger : Logger ,
@@ -131,7 +131,7 @@ async fn handle_connection<S>(
131131 loop {
132132 if let Err ( err) = handle_next (
133133 & logger,
134- & * adapter ,
134+ & * state ,
135135 & mut ws_tx,
136136 & mut ws_rx,
137137 & mut notify_price_tx,
@@ -156,7 +156,7 @@ async fn handle_connection<S>(
156156
157157async fn handle_next < S > (
158158 logger : & Logger ,
159- adapter : & S ,
159+ state : & S ,
160160 ws_tx : & mut SplitSink < WebSocket , Message > ,
161161 ws_rx : & mut SplitStream < WebSocket > ,
162162 notify_price_tx : & mut mpsc:: Sender < NotifyPrice > ,
@@ -175,7 +175,7 @@ where
175175 handle(
176176 logger,
177177 ws_tx,
178- adapter ,
178+ state ,
179179 notify_price_tx,
180180 notify_price_sched_tx,
181181 msg,
@@ -201,7 +201,7 @@ where
201201async fn handle < S > (
202202 logger : & Logger ,
203203 ws_tx : & mut SplitSink < WebSocket , Message > ,
204- adapter : & S ,
204+ state : & S ,
205205 notify_price_tx : & mpsc:: Sender < NotifyPrice > ,
206206 notify_price_sched_tx : & mpsc:: Sender < NotifyPriceSched > ,
207207 msg : Message ,
@@ -224,7 +224,7 @@ where
224224 for request in requests {
225225 let response = dispatch_and_catch_error (
226226 logger,
227- adapter ,
227+ state ,
228228 notify_price_tx,
229229 notify_price_sched_tx,
230230 & request,
@@ -287,7 +287,7 @@ async fn parse(msg: Message) -> Result<(Vec<Request<Method, Value>>, bool)> {
287287
288288async fn dispatch_and_catch_error < S > (
289289 logger : & Logger ,
290- adapter : & S ,
290+ state : & S ,
291291 notify_price_tx : & mpsc:: Sender < NotifyPrice > ,
292292 notify_price_sched_tx : & mpsc:: Sender < NotifyPriceSched > ,
293293 request : & Request < Method , Value > ,
@@ -302,13 +302,13 @@ where
302302 ) ;
303303
304304 let result = match request. method {
305- Method :: GetProductList => get_product_list ( adapter ) . await ,
306- Method :: GetProduct => get_product ( adapter , request) . await ,
307- Method :: GetAllProducts => get_all_products ( adapter ) . await ,
308- Method :: UpdatePrice => update_price ( adapter , request) . await ,
309- Method :: SubscribePrice => subscribe_price ( adapter , notify_price_tx, request) . await ,
305+ Method :: GetProductList => get_product_list ( state ) . await ,
306+ Method :: GetProduct => get_product ( state , request) . await ,
307+ Method :: GetAllProducts => get_all_products ( state ) . await ,
308+ Method :: UpdatePrice => update_price ( state , request) . await ,
309+ Method :: SubscribePrice => subscribe_price ( state , notify_price_tx, request) . await ,
310310 Method :: SubscribePriceSched => {
311- subscribe_price_sched ( adapter , notify_price_sched_tx, request) . await
311+ subscribe_price_sched ( state , notify_price_sched_tx, request) . await
312312 }
313313 Method :: NotifyPrice | Method :: NotifyPriceSched => {
314314 Err ( anyhow ! ( "unsupported method: {:?}" , request. method) )
@@ -410,10 +410,10 @@ pub struct Config {
410410 /// The address which the websocket API server will listen on.
411411 pub listen_address : String ,
412412 /// Size of the buffer of each Server's channel on which `notify_price` events are
413- /// received from the Adapter .
413+ /// received from the Price state .
414414 pub notify_price_tx_buffer : usize ,
415415 /// Size of the buffer of each Server's channel on which `notify_price_sched` events are
416- /// received from the Adapter .
416+ /// received from the Price state .
417417 pub notify_price_sched_tx_buffer : usize ,
418418}
419419
@@ -427,20 +427,20 @@ impl Default for Config {
427427 }
428428}
429429
430- pub async fn run < S > ( config : Config , logger : Logger , adapter : Arc < S > )
430+ pub async fn run < S > ( config : Config , logger : Logger , state : Arc < S > )
431431where
432432 S : state:: Prices ,
433433 S : Send ,
434434 S : Sync ,
435435 S : ' static ,
436436{
437- if let Err ( err) = serve ( config, & logger, adapter ) . await {
437+ if let Err ( err) = serve ( config, & logger, state ) . await {
438438 error ! ( logger, "{}" , err) ;
439439 debug ! ( logger, "error context" ; "context" => format!( "{:?}" , err) ) ;
440440 }
441441}
442442
443- async fn serve < S > ( config : Config , logger : & Logger , adapter : Arc < S > ) -> Result < ( ) >
443+ async fn serve < S > ( config : Config , logger : & Logger , state : Arc < S > ) -> Result < ( ) >
444444where
445445 S : state:: Prices ,
446446 S : Send ,
@@ -456,16 +456,16 @@ where
456456 let config = config. clone ( ) ;
457457 warp:: path:: end ( )
458458 . and ( warp:: ws ( ) )
459- . and ( warp:: any ( ) . map ( move || adapter . clone ( ) ) )
459+ . and ( warp:: any ( ) . map ( move || state . clone ( ) ) )
460460 . and ( warp:: any ( ) . map ( move || with_logger. clone ( ) ) )
461461 . and ( warp:: any ( ) . map ( move || config. clone ( ) ) )
462462 . map (
463- |ws : Ws , adapter : Arc < S > , with_logger : WithLogger , config : Config | {
463+ |ws : Ws , state : Arc < S > , with_logger : WithLogger , config : Config | {
464464 ws. on_upgrade ( move |conn| async move {
465465 info ! ( with_logger. logger, "websocket user connected" ) ;
466466 handle_connection (
467467 conn,
468- adapter ,
468+ state ,
469469 config. notify_price_tx_buffer ,
470470 config. notify_price_sched_tx_buffer ,
471471 with_logger. logger ,
0 commit comments