-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dont keep persistent gateway connections. instead make them on demand
- Loading branch information
Showing
13 changed files
with
235 additions
and
544 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
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 <[email protected]> | ||
// 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 | ||
} | ||
} |
102 changes: 0 additions & 102 deletions
102
nym-api/src/network_monitor/monitor/gateway_clients_cache.rs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.