-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: dont keep persistent GatewayClient inside NMv1 (#5211)
* removed overly complex logic for requesting mutex permits for packet processing * dont keep persistent gateway connections. instead make them on demand
- Loading branch information
Showing
15 changed files
with
342 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
nym-api/src/network_monitor/monitor/gateway_client_handle.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net> | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
use crate::network_monitor::monitor::receiver::{GatewayClientUpdate, GatewayClientUpdateSender}; | ||
use crate::support::nyxd; | ||
use nym_credential_storage::persistent_storage::PersistentStorage; | ||
use nym_gateway_client::GatewayClient; | ||
use std::ops::{Deref, DerefMut}; | ||
use tracing::warn; | ||
|
||
pub(crate) struct GatewayClientHandle { | ||
client: GatewayClient<nyxd::Client, PersistentStorage>, | ||
gateways_status_updater: GatewayClientUpdateSender, | ||
} | ||
|
||
impl GatewayClientHandle { | ||
pub(crate) fn new( | ||
client: GatewayClient<nyxd::Client, PersistentStorage>, | ||
gateways_status_updater: GatewayClientUpdateSender, | ||
) -> Self { | ||
GatewayClientHandle { | ||
client, | ||
gateways_status_updater, | ||
} | ||
} | ||
} | ||
|
||
impl Drop for GatewayClientHandle { | ||
fn drop(&mut self) { | ||
if self | ||
.gateways_status_updater | ||
.unbounded_send(GatewayClientUpdate::Disconnect( | ||
self.client.gateway_identity(), | ||
)) | ||
.is_err() | ||
{ | ||
warn!("fail to cleanly shutdown gateway connection") | ||
} | ||
} | ||
} | ||
|
||
impl Deref for GatewayClientHandle { | ||
type Target = GatewayClient<nyxd::Client, PersistentStorage>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.client | ||
} | ||
} | ||
|
||
impl DerefMut for GatewayClientHandle { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.client | ||
} | ||
} |
Oops, something went wrong.