Skip to content

Commit ee5a8d4

Browse files
committed
Serde as Url directly (instead as String)
1 parent cfc1ede commit ee5a8d4

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

trino-lb-core/src/trino_api.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ pub struct TrinoQueryApiResponse {
4949
pub id: TrinoQueryId,
5050

5151
/// Normally this will always be set, only the last call will not return a `next_uri`.
52-
pub next_uri: Option<String>,
53-
pub info_uri: String,
54-
pub partial_cancel_uri: Option<String>,
52+
pub next_uri: Option<Url>,
53+
pub info_uri: Url,
54+
pub partial_cancel_uri: Option<Url>,
5555

5656
pub columns: Option<Box<RawValue>>,
5757
pub data: Option<Box<Value>>,
@@ -102,8 +102,7 @@ impl TrinoQueryApiResponse {
102102
)]
103103
pub fn change_next_uri_to_trino_lb(&mut self, trino_lb_addr: &Url) -> Result<(), Error> {
104104
if let Some(next_uri) = &self.next_uri {
105-
let next_uri = Url::parse(next_uri).context(ParseNextUriFromTrinoSnafu)?;
106-
self.next_uri = Some(change_next_uri_to_trino_lb(&next_uri, trino_lb_addr).to_string());
105+
self.next_uri = Some(change_next_uri_to_trino_lb(next_uri, trino_lb_addr));
107106
}
108107

109108
Ok(())
@@ -138,15 +137,13 @@ impl TrinoQueryApiResponse {
138137
))
139138
.context(JoinApiPathToTrinoLbUrlSnafu {
140139
trino_lb_addr: trino_lb_addr.clone(),
141-
})?
142-
.to_string(),
140+
})?,
143141
),
144142
info_uri: trino_lb_addr
145143
.join(&format!("ui/query.html?{query_id}"))
146144
.context(JoinApiPathToTrinoLbUrlSnafu {
147145
trino_lb_addr: trino_lb_addr.clone(),
148-
})?
149-
.to_string(),
146+
})?,
150147
partial_cancel_uri: None,
151148
columns: None,
152149
data: None,
@@ -196,8 +193,7 @@ impl TrinoQueryApiResponse {
196193
) -> Result<(), Error> {
197194
// Point nextUri to trino-lb
198195
if let Some(next_uri) = &self.next_uri {
199-
let next_uri = Url::parse(next_uri).context(ParseNextUriFromTrinoSnafu)?;
200-
self.next_uri = Some(change_next_uri_to_trino_lb(&next_uri, trino_lb_addr).to_string());
196+
self.next_uri = Some(change_next_uri_to_trino_lb(next_uri, trino_lb_addr));
201197
}
202198

203199
// Point segment ackUris to Trino

0 commit comments

Comments
 (0)