@@ -10,8 +10,7 @@ use std::{
1010 time:: Duration ,
1111} ;
1212
13- use futures:: future:: { self , ready, Either , Future } ;
14- use futures:: prelude:: TryFutureExt ;
13+ use futures:: prelude:: * ;
1514use grpcio:: { EnvBuilder , Environment } ;
1615use kvproto:: kvrpcpb;
1716use log:: * ;
@@ -153,33 +152,31 @@ impl RpcClient {
153152 let inner = self . inner ( ) ;
154153 loop_fn ( ( 0 , tasks, result) , move |( mut index, tasks, mut result) | {
155154 if index == tasks. len ( ) {
156- Either :: Left ( future:: ok ( Loop :: Break ( result) ) )
155+ future :: Either :: Left ( future:: ok ( Loop :: Break ( result) ) )
157156 } else {
158157 let inner = Arc :: clone ( & inner) ;
159- Either :: Right (
160- inner
161- . locate_key ( tasks[ index] . key ( ) )
162- . map_ok ( move |location| {
163- while let Some ( item) = tasks. get ( index) {
164- if !location. contains ( item. key ( ) ) {
165- break ;
166- }
167- let ver_id = location. ver_id ( ) ;
168- let item = item. clone ( ) ;
169- if let Some ( ref mut grouped) = result {
170- grouped. add ( ver_id, item) ;
171- } else {
172- result = Some ( GroupedTasks :: new ( ver_id, item) ) ;
173- }
174- index += 1 ;
158+ future:: Either :: Right ( inner. locate_key ( tasks[ index] . key ( ) ) . map_ok (
159+ move |location| {
160+ while let Some ( item) = tasks. get ( index) {
161+ if !location. contains ( item. key ( ) ) {
162+ break ;
175163 }
176- if index == tasks. len ( ) {
177- Loop :: Break ( result)
164+ let ver_id = location. ver_id ( ) ;
165+ let item = item. clone ( ) ;
166+ if let Some ( ref mut grouped) = result {
167+ grouped. add ( ver_id, item) ;
178168 } else {
179- Loop :: Continue ( ( index , tasks , result ) )
169+ result = Some ( GroupedTasks :: new ( ver_id , item ) ) ;
180170 }
181- } ) ,
182- )
171+ index += 1 ;
172+ }
173+ if index == tasks. len ( ) {
174+ Loop :: Break ( result)
175+ } else {
176+ Loop :: Continue ( ( index, tasks, result) )
177+ }
178+ } ,
179+ ) )
183180 }
184181 } )
185182 . map_ok ( |r| r. unwrap_or_default ( ) )
@@ -200,7 +197,7 @@ impl RpcClient {
200197 store,
201198 } )
202199 } )
203- . and_then ( move |region| ready ( inner2. kv_client ( region) ) )
200+ . and_then ( move |region| future :: ready ( inner2. kv_client ( region) ) )
204201 }
205202
206203 fn region_context_by_id (
@@ -217,7 +214,7 @@ impl RpcClient {
217214 . load_store ( store_id)
218215 . map_ok ( |store| RegionContext { region, store } )
219216 } )
220- . and_then ( move |region| ready ( inner2. kv_client ( region) ) )
217+ . and_then ( move |region| future :: ready ( inner2. kv_client ( region) ) )
221218 }
222219
223220 fn raw (
@@ -279,9 +276,9 @@ impl RpcClient {
279276 cf : Option < ColumnFamily > ,
280277 ) -> impl Future < Output = Result < ( ) > > {
281278 if value. is_empty ( ) {
282- Either :: Left ( future:: err ( Error :: empty_value ( ) ) )
279+ future :: Either :: Left ( future:: err ( Error :: empty_value ( ) ) )
283280 } else {
284- Either :: Right (
281+ future :: Either :: Right (
285282 Self :: raw ( self . inner ( ) , & key, cf)
286283 . and_then ( |context| context. client ( ) . raw_put ( context, key, value) ) ,
287284 )
@@ -294,10 +291,10 @@ impl RpcClient {
294291 cf : Option < ColumnFamily > ,
295292 ) -> impl Future < Output = Result < ( ) > > {
296293 if pairs. iter ( ) . any ( |p| p. value ( ) . is_empty ( ) ) {
297- Either :: Left ( future:: err ( Error :: empty_value ( ) ) )
294+ future :: Either :: Left ( future:: err ( Error :: empty_value ( ) ) )
298295 } else {
299296 let inner = self . inner ( ) ;
300- Either :: Right (
297+ future :: Either :: Right (
301298 self . group_tasks_by_region ( pairs)
302299 . and_then ( move |task_groups| {
303300 let mut tasks = Vec :: with_capacity ( task_groups. len ( ) ) ;
0 commit comments