Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Mar 14, 2024
1 parent 1947d3f commit efcb2bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
12 changes: 6 additions & 6 deletions apollo-router/src/plugins/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl SubscriptionModeConfig {
if callback_cfg.subgraphs.contains(service_name) || callback_cfg.subgraphs.is_empty() {
let callback_cfg = CallbackMode {
public_url: callback_cfg.public_url.clone(),
heartbeat_interval: callback_cfg.heartbeat_interval.clone(),
heartbeat_interval: callback_cfg.heartbeat_interval,
listen: callback_cfg.listen.clone(),
path: callback_cfg.path.clone(),
subgraphs: HashSet::new(), // We don't need it
Expand Down Expand Up @@ -168,7 +168,7 @@ pub(crate) struct CallbackMode {
pub(crate) subgraphs: HashSet<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case", untagged)]
pub(crate) enum HeartbeatInterval {
Disabled(Disabled),
Expand All @@ -186,22 +186,22 @@ impl HeartbeatInterval {
pub(crate) fn new_disabled() -> Self {
Self::Disabled(Disabled::Disabled)
}
pub(crate) fn into_option(&self) -> Option<Duration> {
pub(crate) fn into_option(self) -> Option<Duration> {
match self {
Self::Disabled(_) => None,
Self::Enabled(_) => Some(Duration::from_secs(5)),
Self::Duration(duration) => Some(*duration),
Self::Duration(duration) => Some(duration),
}
}
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub(crate) enum Disabled {
Disabled,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub(crate) enum Enabled {
Enabled,
Expand Down
22 changes: 9 additions & 13 deletions apollo-router/src/protocols/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,19 +445,15 @@ where
}

fn send_heartbeat(mut stream: Pin<&mut impl Sink<ClientMessage>>, cx: &mut std::task::Context<'_>) {
match stream.as_mut().poll_flush(cx) {
Poll::Ready(Ok(_)) => match stream.as_mut().poll_ready(cx) {
Poll::Ready(Ok(_)) => {
// Ignore error
let _ = stream.start_send(ClientMessage::Ping {
payload: Some(serde_json_bytes::Value::String(
"APOLLO_ROUTER_HEARTBEAT".into()
))
});
}
_ => (),
},
_ => (),
if stream.as_mut().poll_flush(cx).map(|result| result.is_ok()) == Poll::Ready(true)
&& stream.as_mut().poll_ready(cx).map(|result| result.is_ok()) == Poll::Ready(true)
{
// Ignore error
let _ = stream.start_send(ClientMessage::Ping {
payload: Some(serde_json_bytes::Value::String(
"APOLLO_ROUTER_HEARTBEAT".into(),
)),
});
}
}

Expand Down

0 comments on commit efcb2bf

Please sign in to comment.