10
10
11
11
use arrow_flight:: encode:: FlightDataEncoderBuilder ;
12
12
use arrow_flight:: error:: FlightError ;
13
- use bytes:: Bytes ;
14
13
use futures:: stream:: BoxStream ;
15
14
use futures:: TryStreamExt ;
16
15
use restate_core:: network:: protobuf:: node_svc:: node_svc_server:: NodeSvc ;
@@ -21,10 +20,8 @@ use restate_core::network::{ConnectionManager, GrpcConnector};
21
20
use restate_core:: { metadata, TaskCenter } ;
22
21
use restate_types:: protobuf:: common:: NodeStatus ;
23
22
use restate_types:: protobuf:: node:: Message ;
24
- use std:: str:: FromStr ;
25
23
use tokio_stream:: StreamExt ;
26
- use tonic:: metadata:: { MetadataKey , MetadataMap , MetadataValue } ;
27
- use tonic:: { Code , Request , Response , Status , Streaming } ;
24
+ use tonic:: { Request , Response , Status , Streaming } ;
28
25
29
26
use crate :: network_server:: WorkerDependencies ;
30
27
@@ -133,43 +130,9 @@ fn flight_error_to_tonic_status(err: FlightError) -> Status {
133
130
match err {
134
131
FlightError :: Arrow ( e) => Status :: internal ( e. to_string ( ) ) ,
135
132
FlightError :: NotYetImplemented ( e) => Status :: internal ( e) ,
136
- FlightError :: Tonic ( status) => tonic_status_010_to_012 ( status) ,
133
+ FlightError :: Tonic ( status) => status,
137
134
FlightError :: ProtocolError ( e) => Status :: internal ( e) ,
138
135
FlightError :: DecodeError ( e) => Status :: internal ( e) ,
139
136
FlightError :: ExternalError ( e) => Status :: internal ( e. to_string ( ) ) ,
140
137
}
141
138
}
142
-
143
- // todo: Remove once arrow-flight works with tonic 0.12
144
- fn tonic_status_010_to_012 ( status : tonic_0_11:: Status ) -> Status {
145
- let code = Code :: from ( status. code ( ) as i32 ) ;
146
- let message = status. message ( ) . to_owned ( ) ;
147
- let details = Bytes :: copy_from_slice ( status. details ( ) ) ;
148
- let metadata = tonic_metadata_map_010_to_012 ( status. metadata ( ) ) ;
149
- Status :: with_details_and_metadata ( code, message, details, metadata)
150
- }
151
-
152
- // todo: Remove once arrow-flight works with tonic 0.12
153
- fn tonic_metadata_map_010_to_012 ( metadata_map : & tonic_0_11:: metadata:: MetadataMap ) -> MetadataMap {
154
- let mut resulting_metadata_map = MetadataMap :: with_capacity ( metadata_map. len ( ) ) ;
155
- for key_value in metadata_map. iter ( ) {
156
- match key_value {
157
- tonic_0_11:: metadata:: KeyAndValueRef :: Ascii ( key, value) => {
158
- // ignore metadata map entries if conversion fails
159
- if let Ok ( value) = MetadataValue :: from_str ( value. to_str ( ) . unwrap_or ( "" ) ) {
160
- if let Ok ( key) = MetadataKey :: from_str ( key. as_str ( ) ) {
161
- resulting_metadata_map. insert ( key, value) ;
162
- }
163
- }
164
- }
165
- tonic_0_11:: metadata:: KeyAndValueRef :: Binary ( key, value) => {
166
- if let Ok ( key) = MetadataKey :: from_bytes ( key. as_ref ( ) ) {
167
- let value = MetadataValue :: from_bytes ( value. as_ref ( ) ) ;
168
- resulting_metadata_map. insert_bin ( key, value) ;
169
- }
170
- }
171
- }
172
- }
173
-
174
- resulting_metadata_map
175
- }
0 commit comments