[Product Data] Introduce data persistence on gateways (#5022)
* add stats storage to gateways * config fix * add stats storage model and logic * adapt stats collection to new storage * stats cleanup on start * change to linux only code * tweaks * modified stats cleanup + change session started * change wrong table name * store crashed session as 0 duration * adapt for sqlx 0.7 * remove unused dependencies * revert changes from gateway config, as it is broken anyway * copyright and misc stuff --------- Co-authored-by: Simon Wicky <simon@linode2-2.net>
This commit is contained in:
@@ -67,6 +67,7 @@ impl MixnodeData {
|
||||
pub struct EntryGatewayData {
|
||||
mnemonic: Zeroizing<bip39::Mnemonic>,
|
||||
client_storage: nym_gateway::node::PersistentStorage,
|
||||
stats_storage: nym_gateway::node::PersistentStatsStorage,
|
||||
sessions_stats: SharedSessionStats,
|
||||
}
|
||||
|
||||
@@ -94,6 +95,11 @@ impl EntryGatewayData {
|
||||
)
|
||||
.await
|
||||
.map_err(nym_gateway::GatewayError::from)?,
|
||||
stats_storage: nym_gateway::node::PersistentStatsStorage::init(
|
||||
&config.storage_paths.stats_storage,
|
||||
)
|
||||
.await
|
||||
.map_err(nym_gateway::GatewayError::from)?,
|
||||
sessions_stats: SharedSessionStats::new(),
|
||||
})
|
||||
}
|
||||
@@ -114,6 +120,7 @@ pub struct ExitGatewayData {
|
||||
auth_x25519: x25519::PublicKey,
|
||||
|
||||
client_storage: nym_gateway::node::PersistentStorage,
|
||||
stats_storage: nym_gateway::node::PersistentStatsStorage,
|
||||
}
|
||||
|
||||
impl ExitGatewayData {
|
||||
@@ -262,6 +269,11 @@ impl ExitGatewayData {
|
||||
.await
|
||||
.map_err(nym_gateway::GatewayError::from)?;
|
||||
|
||||
let stats_storage =
|
||||
nym_gateway::node::PersistentStatsStorage::init(&config.storage_paths.stats_storage)
|
||||
.await
|
||||
.map_err(nym_gateway::GatewayError::from)?;
|
||||
|
||||
Ok(ExitGatewayData {
|
||||
nr_ed25519,
|
||||
nr_x25519,
|
||||
@@ -270,6 +282,7 @@ impl ExitGatewayData {
|
||||
auth_ed25519,
|
||||
auth_x25519,
|
||||
client_storage,
|
||||
stats_storage,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -580,6 +593,7 @@ impl NymNode {
|
||||
self.ed25519_identity_keys.clone(),
|
||||
self.x25519_sphinx_keys.clone(),
|
||||
self.entry_gateway.client_storage.clone(),
|
||||
self.entry_gateway.stats_storage.clone(),
|
||||
);
|
||||
entry_gateway.disable_http_server();
|
||||
entry_gateway.set_task_client(task_client);
|
||||
@@ -610,6 +624,7 @@ impl NymNode {
|
||||
self.ed25519_identity_keys.clone(),
|
||||
self.x25519_sphinx_keys.clone(),
|
||||
self.exit_gateway.client_storage.clone(),
|
||||
self.exit_gateway.stats_storage.clone(),
|
||||
);
|
||||
exit_gateway.disable_http_server();
|
||||
exit_gateway.set_task_client(task_client);
|
||||
|
||||
Reference in New Issue
Block a user