@@ -9,6 +9,7 @@ use error_stack::ResultExt;
9
9
use http_body_util:: combinators:: UnsyncBoxBody ;
10
10
use hyper:: body:: Bytes ;
11
11
use hyper_util:: client:: legacy:: connect:: HttpConnector ;
12
+ use router_env:: logger;
12
13
use serde;
13
14
use success_rate:: {
14
15
success_rate_calculator_client:: SuccessRateCalculatorClient , CalSuccessRateConfig ,
@@ -80,6 +81,7 @@ impl DynamicRoutingClientConfig {
80
81
let success_rate_client = match self {
81
82
Self :: Enabled { host, port } => {
82
83
let uri = format ! ( "http://{}:{}" , host, port) . parse :: < tonic:: transport:: Uri > ( ) ?;
84
+ logger:: info!( "Connection established with dynamic routing gRPC Server" ) ;
83
85
Some ( SuccessRateCalculatorClient :: with_origin ( client, uri) )
84
86
}
85
87
Self :: Disabled => None ,
@@ -98,13 +100,15 @@ pub trait SuccessBasedDynamicRouting: dyn_clone::DynClone + Send + Sync {
98
100
& self ,
99
101
id : String ,
100
102
success_rate_based_config : SuccessBasedRoutingConfig ,
103
+ params : String ,
101
104
label_input : Vec < RoutableConnectorChoice > ,
102
105
) -> DynamicRoutingResult < CalSuccessRateResponse > ;
103
106
/// To update the success rate with the given label
104
107
async fn update_success_rate (
105
108
& self ,
106
109
id : String ,
107
110
success_rate_based_config : SuccessBasedRoutingConfig ,
111
+ params : String ,
108
112
response : Vec < RoutableConnectorChoiceWithStatus > ,
109
113
) -> DynamicRoutingResult < UpdateSuccessRateWindowResponse > ;
110
114
}
@@ -115,24 +119,9 @@ impl SuccessBasedDynamicRouting for SuccessRateCalculatorClient<Client> {
115
119
& self ,
116
120
id : String ,
117
121
success_rate_based_config : SuccessBasedRoutingConfig ,
122
+ params : String ,
118
123
label_input : Vec < RoutableConnectorChoice > ,
119
124
) -> DynamicRoutingResult < CalSuccessRateResponse > {
120
- let params = success_rate_based_config
121
- . params
122
- . map ( |vec| {
123
- vec. into_iter ( ) . fold ( String :: new ( ) , |mut acc_str, params| {
124
- if !acc_str. is_empty ( ) {
125
- acc_str. push ( ':' )
126
- }
127
- acc_str. push_str ( params. to_string ( ) . as_str ( ) ) ;
128
- acc_str
129
- } )
130
- } )
131
- . get_required_value ( "params" )
132
- . change_context ( DynamicRoutingError :: MissingRequiredField {
133
- field : "params" . to_string ( ) ,
134
- } ) ?;
135
-
136
125
let labels = label_input
137
126
. into_iter ( )
138
127
. map ( |conn_choice| conn_choice. to_string ( ) )
@@ -167,6 +156,7 @@ impl SuccessBasedDynamicRouting for SuccessRateCalculatorClient<Client> {
167
156
& self ,
168
157
id : String ,
169
158
success_rate_based_config : SuccessBasedRoutingConfig ,
159
+ params : String ,
170
160
label_input : Vec < RoutableConnectorChoiceWithStatus > ,
171
161
) -> DynamicRoutingResult < UpdateSuccessRateWindowResponse > {
172
162
let config = success_rate_based_config
@@ -182,22 +172,6 @@ impl SuccessBasedDynamicRouting for SuccessRateCalculatorClient<Client> {
182
172
} )
183
173
. collect ( ) ;
184
174
185
- let params = success_rate_based_config
186
- . params
187
- . map ( |vec| {
188
- vec. into_iter ( ) . fold ( String :: new ( ) , |mut acc_str, params| {
189
- if !acc_str. is_empty ( ) {
190
- acc_str. push ( ':' )
191
- }
192
- acc_str. push_str ( params. to_string ( ) . as_str ( ) ) ;
193
- acc_str
194
- } )
195
- } )
196
- . get_required_value ( "params" )
197
- . change_context ( DynamicRoutingError :: MissingRequiredField {
198
- field : "params" . to_string ( ) ,
199
- } ) ?;
200
-
201
175
let request = tonic:: Request :: new ( UpdateSuccessRateWindowRequest {
202
176
id,
203
177
params,
0 commit comments