0.3.5
This commit is contained in:
@@ -10,3 +10,4 @@
|
|||||||
0.3.2 - Ajout des helpers typed et du parsing typed basé sur solana-rpc-client-api
|
0.3.2 - Ajout des helpers typed et du parsing typed basé sur solana-rpc-client-api
|
||||||
0.3.3 - Ajout du suffixe _raw aux helpers raw pour distinguer typed et raw
|
0.3.3 - Ajout du suffixe _raw aux helpers raw pour distinguer typed et raw
|
||||||
0.3.4 - Ajout de la fenêtre Demo Ws dans kb_app pour tester les souscriptions live
|
0.3.4 - Ajout de la fenêtre Demo Ws dans kb_app pour tester les souscriptions live
|
||||||
|
0.3.5 - Stabilisation de Demo Ws, lecture correcte des endpoints activés depuis la config, limitation/throttling de l’affichage UI sous fort débit
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ members = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.3.4"
|
version = "0.3.5"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://git.sasedev.com/Sasedev/khadhroony-bobobot"
|
repository = "https://git.sasedev.com/Sasedev/khadhroony-bobobot"
|
||||||
|
|||||||
@@ -43,9 +43,14 @@
|
|||||||
<h2 class="h5 mb-3">Connexion</h2>
|
<h2 class="h5 mb-3">Connexion</h2>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="demoWsEndpointSelect" class="form-label">Endpoint</label>
|
<label for="demoWsEndpointSelect" class="form-label">Endpoint WS activé</label>
|
||||||
<select id="demoWsEndpointSelect" class="form-select"></select>
|
<select id="demoWsEndpointSelect" class="form-select"></select>
|
||||||
|
<div class="form-text">
|
||||||
|
Seuls les endpoints définis dans <code>config.solana.ws_endpoints</code> et marqués
|
||||||
|
<code>enabled: true</code> apparaissent ici. Les endpoints HTTP ne sont pas utilisés
|
||||||
|
par cette fenêtre.
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="d-flex flex-wrap gap-2 mb-3">
|
<div class="d-flex flex-wrap gap-2 mb-3">
|
||||||
<button id="demoWsConnectButton" type="button" class="btn btn-success">Connect</button>
|
<button id="demoWsConnectButton" type="button" class="btn btn-success">Connect</button>
|
||||||
@@ -57,6 +62,14 @@
|
|||||||
<div><strong>Endpoint:</strong> <span id="demoWsEndpointText">-</span></div>
|
<div><strong>Endpoint:</strong> <span id="demoWsEndpointText">-</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="small text-body-secondary mt-2">
|
||||||
|
<div><strong>Events:</strong> <span id="demoWsEventCountText">0</span></div>
|
||||||
|
<div><strong>Notifications:</strong> <span id="demoWsNotificationCountText">0</span></div>
|
||||||
|
<div><strong>UI logs:</strong> <span id="demoWsUiLogCountText">0</span></div>
|
||||||
|
<div><strong>Suppressed:</strong> <span id="demoWsSuppressedLogCountText">0</span></div>
|
||||||
|
<div><strong>Last event:</strong> <span id="demoWsLastEventKindText">-</span></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<h2 class="h5 mb-3">Souscription</h2>
|
<h2 class="h5 mb-3">Souscription</h2>
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ interface DemoWsStatusPayload {
|
|||||||
currentSubscribeMethod: string | null;
|
currentSubscribeMethod: string | null;
|
||||||
currentUnsubscribeMethod: string | null;
|
currentUnsubscribeMethod: string | null;
|
||||||
currentNotificationMethod: string | null;
|
currentNotificationMethod: string | null;
|
||||||
|
eventCountTotal: number;
|
||||||
|
notificationCountTotal: number;
|
||||||
|
uiLogCount: number;
|
||||||
|
suppressedLogCount: number;
|
||||||
|
lastEventKind: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DemoWsSubscribeRequest {
|
interface DemoWsSubscribeRequest {
|
||||||
@@ -195,6 +200,11 @@ function applyStatusToUi(
|
|||||||
stateText: HTMLSpanElement,
|
stateText: HTMLSpanElement,
|
||||||
endpointText: HTMLSpanElement,
|
endpointText: HTMLSpanElement,
|
||||||
subscriptionText: HTMLSpanElement,
|
subscriptionText: HTMLSpanElement,
|
||||||
|
eventCountText: HTMLSpanElement,
|
||||||
|
notificationCountText: HTMLSpanElement,
|
||||||
|
uiLogCountText: HTMLSpanElement,
|
||||||
|
suppressedLogCountText: HTMLSpanElement,
|
||||||
|
lastEventKindText: HTMLSpanElement,
|
||||||
connectButton: HTMLButtonElement,
|
connectButton: HTMLButtonElement,
|
||||||
disconnectButton: HTMLButtonElement,
|
disconnectButton: HTMLButtonElement,
|
||||||
subscribeButton: HTMLButtonElement,
|
subscribeButton: HTMLButtonElement,
|
||||||
@@ -213,6 +223,12 @@ function applyStatusToUi(
|
|||||||
subscriptionText.textContent = "-";
|
subscriptionText.textContent = "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventCountText.textContent = String(status.eventCountTotal);
|
||||||
|
notificationCountText.textContent = String(status.notificationCountTotal);
|
||||||
|
uiLogCountText.textContent = String(status.uiLogCount);
|
||||||
|
suppressedLogCountText.textContent = String(status.suppressedLogCount);
|
||||||
|
lastEventKindText.textContent = status.lastEventKind ?? "-";
|
||||||
|
|
||||||
const isConnected = status.connectionState === "Connected";
|
const isConnected = status.connectionState === "Connected";
|
||||||
const isBusy = status.connectionState === "Connecting" || status.connectionState === "Disconnecting";
|
const isBusy = status.connectionState === "Connecting" || status.connectionState === "Disconnecting";
|
||||||
|
|
||||||
@@ -273,6 +289,11 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
const endpointText = document.querySelector<HTMLSpanElement>("#demoWsEndpointText");
|
const endpointText = document.querySelector<HTMLSpanElement>("#demoWsEndpointText");
|
||||||
const subscriptionText = document.querySelector<HTMLSpanElement>("#demoWsSubscriptionText");
|
const subscriptionText = document.querySelector<HTMLSpanElement>("#demoWsSubscriptionText");
|
||||||
const requestText = document.querySelector<HTMLSpanElement>("#demoWsRequestText");
|
const requestText = document.querySelector<HTMLSpanElement>("#demoWsRequestText");
|
||||||
|
const eventCountText = document.querySelector<HTMLSpanElement>("#demoWsEventCountText");
|
||||||
|
const notificationCountText = document.querySelector<HTMLSpanElement>("#demoWsNotificationCountText");
|
||||||
|
const uiLogCountText = document.querySelector<HTMLSpanElement>("#demoWsUiLogCountText");
|
||||||
|
const suppressedLogCountText = document.querySelector<HTMLSpanElement>("#demoWsSuppressedLogCountText");
|
||||||
|
const lastEventKindText = document.querySelector<HTMLSpanElement>("#demoWsLastEventKindText");
|
||||||
const connectButton = document.querySelector<HTMLButtonElement>("#demoWsConnectButton");
|
const connectButton = document.querySelector<HTMLButtonElement>("#demoWsConnectButton");
|
||||||
const disconnectButton = document.querySelector<HTMLButtonElement>("#demoWsDisconnectButton");
|
const disconnectButton = document.querySelector<HTMLButtonElement>("#demoWsDisconnectButton");
|
||||||
const subscribeButton = document.querySelector<HTMLButtonElement>("#demoWsSubscribeButton");
|
const subscribeButton = document.querySelector<HTMLButtonElement>("#demoWsSubscribeButton");
|
||||||
@@ -281,6 +302,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
const logTextarea = document.querySelector<HTMLTextAreaElement>("#demoWsLogTextarea");
|
const logTextarea = document.querySelector<HTMLTextAreaElement>("#demoWsLogTextarea");
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
!eventCountText || !notificationCountText || !uiLogCountText || !suppressedLogCountText || !lastEventKindText ||
|
||||||
!endpointSelect || !methodSelect || !modeSelect || !targetGroup || !targetLabel || !targetInput ||
|
!endpointSelect || !methodSelect || !modeSelect || !targetGroup || !targetLabel || !targetInput ||
|
||||||
!filterGroup || !filterTextarea || !configGroup || !configTextarea || !statusBadge ||
|
!filterGroup || !filterTextarea || !configGroup || !configTextarea || !statusBadge ||
|
||||||
!stateText || !endpointText || !subscriptionText || !requestText || !connectButton ||
|
!stateText || !endpointText || !subscriptionText || !requestText || !connectButton ||
|
||||||
@@ -305,12 +327,17 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
stateText,
|
stateText,
|
||||||
endpointText,
|
endpointText,
|
||||||
subscriptionText,
|
subscriptionText,
|
||||||
|
eventCountText,
|
||||||
|
notificationCountText,
|
||||||
|
uiLogCountText,
|
||||||
|
suppressedLogCountText,
|
||||||
|
lastEventKindText,
|
||||||
connectButton,
|
connectButton,
|
||||||
disconnectButton,
|
disconnectButton,
|
||||||
subscribeButton,
|
subscribeButton,
|
||||||
unsubscribeButton,
|
unsubscribeButton,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
appendLogLine(logTextarea, `[ui] event listen error: ${String(error)}`);
|
appendLogLine(logTextarea, `[ui] event listen error: ${String(error)}`);
|
||||||
}
|
}
|
||||||
@@ -378,11 +405,16 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
stateText,
|
stateText,
|
||||||
endpointText,
|
endpointText,
|
||||||
subscriptionText,
|
subscriptionText,
|
||||||
|
eventCountText,
|
||||||
|
notificationCountText,
|
||||||
|
uiLogCountText,
|
||||||
|
suppressedLogCountText,
|
||||||
|
lastEventKindText,
|
||||||
connectButton,
|
connectButton,
|
||||||
disconnectButton,
|
disconnectButton,
|
||||||
subscribeButton,
|
subscribeButton,
|
||||||
unsubscribeButton,
|
unsubscribeButton,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
appendLogLine(logTextarea, `[ui] initial status error: ${String(error)}`);
|
appendLogLine(logTextarea, `[ui] initial status error: ${String(error)}`);
|
||||||
}
|
}
|
||||||
@@ -401,11 +433,16 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
stateText,
|
stateText,
|
||||||
endpointText,
|
endpointText,
|
||||||
subscriptionText,
|
subscriptionText,
|
||||||
|
eventCountText,
|
||||||
|
notificationCountText,
|
||||||
|
uiLogCountText,
|
||||||
|
suppressedLogCountText,
|
||||||
|
lastEventKindText,
|
||||||
connectButton,
|
connectButton,
|
||||||
disconnectButton,
|
disconnectButton,
|
||||||
subscribeButton,
|
subscribeButton,
|
||||||
unsubscribeButton,
|
unsubscribeButton,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
appendLogLine(logTextarea, `[ui] connect error: ${String(error)}`);
|
appendLogLine(logTextarea, `[ui] connect error: ${String(error)}`);
|
||||||
}
|
}
|
||||||
@@ -421,11 +458,16 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
stateText,
|
stateText,
|
||||||
endpointText,
|
endpointText,
|
||||||
subscriptionText,
|
subscriptionText,
|
||||||
|
eventCountText,
|
||||||
|
notificationCountText,
|
||||||
|
uiLogCountText,
|
||||||
|
suppressedLogCountText,
|
||||||
|
lastEventKindText,
|
||||||
connectButton,
|
connectButton,
|
||||||
disconnectButton,
|
disconnectButton,
|
||||||
subscribeButton,
|
subscribeButton,
|
||||||
unsubscribeButton,
|
unsubscribeButton,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
appendLogLine(logTextarea, `[ui] disconnect error: ${String(error)}`);
|
appendLogLine(logTextarea, `[ui] disconnect error: ${String(error)}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "kb-app",
|
"name": "kb-app",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.3.0",
|
"version": "0.3.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ pub(crate) struct KbDemoWsStatusPayload {
|
|||||||
current_subscribe_method: std::option::Option<std::string::String>,
|
current_subscribe_method: std::option::Option<std::string::String>,
|
||||||
current_unsubscribe_method: std::option::Option<std::string::String>,
|
current_unsubscribe_method: std::option::Option<std::string::String>,
|
||||||
current_notification_method: std::option::Option<std::string::String>,
|
current_notification_method: std::option::Option<std::string::String>,
|
||||||
|
event_count_total: u64,
|
||||||
|
notification_count_total: u64,
|
||||||
|
ui_log_count: u64,
|
||||||
|
suppressed_log_count: u64,
|
||||||
|
last_event_kind: std::option::Option<std::string::String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subscribe request sent by the demo frontend.
|
/// Subscribe request sent by the demo frontend.
|
||||||
@@ -53,6 +58,12 @@ pub(crate) struct KbDemoWsRuntimeState {
|
|||||||
endpoint_url: std::option::Option<std::string::String>,
|
endpoint_url: std::option::Option<std::string::String>,
|
||||||
connection_state: kb_lib::KbConnectionState,
|
connection_state: kb_lib::KbConnectionState,
|
||||||
current_subscription: std::option::Option<kb_lib::WsSubscriptionInfo>,
|
current_subscription: std::option::Option<kb_lib::WsSubscriptionInfo>,
|
||||||
|
event_count_total: u64,
|
||||||
|
notification_count_total: u64,
|
||||||
|
ui_log_count: u64,
|
||||||
|
suppressed_log_count: u64,
|
||||||
|
last_event_kind: std::option::Option<std::string::String>,
|
||||||
|
last_status_emit_at: std::option::Option<std::time::Instant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KbDemoWsRuntimeState {
|
impl KbDemoWsRuntimeState {
|
||||||
@@ -66,6 +77,12 @@ impl KbDemoWsRuntimeState {
|
|||||||
endpoint_url: None,
|
endpoint_url: None,
|
||||||
connection_state: kb_lib::KbConnectionState::Disconnected,
|
connection_state: kb_lib::KbConnectionState::Disconnected,
|
||||||
current_subscription: None,
|
current_subscription: None,
|
||||||
|
event_count_total: 0,
|
||||||
|
notification_count_total: 0,
|
||||||
|
ui_log_count: 0,
|
||||||
|
suppressed_log_count: 0,
|
||||||
|
last_event_kind: None,
|
||||||
|
last_status_emit_at: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +111,11 @@ impl KbDemoWsRuntimeState {
|
|||||||
current_subscribe_method,
|
current_subscribe_method,
|
||||||
current_unsubscribe_method,
|
current_unsubscribe_method,
|
||||||
current_notification_method,
|
current_notification_method,
|
||||||
|
event_count_total: self.event_count_total,
|
||||||
|
notification_count_total: self.notification_count_total,
|
||||||
|
ui_log_count: self.ui_log_count,
|
||||||
|
suppressed_log_count: self.suppressed_log_count,
|
||||||
|
last_event_kind: self.last_event_kind.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +127,12 @@ impl KbDemoWsRuntimeState {
|
|||||||
self.endpoint_url = None;
|
self.endpoint_url = None;
|
||||||
self.connection_state = kb_lib::KbConnectionState::Disconnected;
|
self.connection_state = kb_lib::KbConnectionState::Disconnected;
|
||||||
self.current_subscription = None;
|
self.current_subscription = None;
|
||||||
|
self.event_count_total = 0;
|
||||||
|
self.notification_count_total = 0;
|
||||||
|
self.ui_log_count = 0;
|
||||||
|
self.suppressed_log_count = 0;
|
||||||
|
self.last_event_kind = None;
|
||||||
|
self.last_status_emit_at = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,10 +182,20 @@ pub(crate) async fn demo_ws_list_endpoints(
|
|||||||
) -> Result<std::vec::Vec<KbDemoWsEndpointSummary>, std::string::String> {
|
) -> Result<std::vec::Vec<KbDemoWsEndpointSummary>, std::string::String> {
|
||||||
let mut endpoints = std::vec::Vec::new();
|
let mut endpoints = std::vec::Vec::new();
|
||||||
for endpoint in &state.config.solana.ws_endpoints {
|
for endpoint in &state.config.solana.ws_endpoints {
|
||||||
|
if !endpoint.enabled {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let resolved_url_result = endpoint.resolved_url();
|
let resolved_url_result = endpoint.resolved_url();
|
||||||
let resolved_url = match resolved_url_result {
|
let resolved_url = match resolved_url_result {
|
||||||
Ok(resolved_url) => resolved_url,
|
Ok(resolved_url) => resolved_url,
|
||||||
Err(_) => endpoint.url.clone(),
|
Err(error) => {
|
||||||
|
tracing::warn!(
|
||||||
|
endpoint_name = %endpoint.name,
|
||||||
|
"cannot resolve ws endpoint url from environment: {}",
|
||||||
|
error
|
||||||
|
);
|
||||||
|
format!("UNRESOLVED_ENV [{}] {}", endpoint.name, endpoint.url)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
endpoints.push(KbDemoWsEndpointSummary {
|
endpoints.push(KbDemoWsEndpointSummary {
|
||||||
name: endpoint.name.clone(),
|
name: endpoint.name.clone(),
|
||||||
@@ -231,10 +269,15 @@ pub(crate) async fn demo_ws_connect(
|
|||||||
let recv_result = event_receiver.recv().await;
|
let recv_result = event_receiver.recv().await;
|
||||||
match recv_result {
|
match recv_result {
|
||||||
Ok(event) => {
|
Ok(event) => {
|
||||||
kb_apply_demo_ws_event_to_runtime(&relay_runtime, &event).await;
|
let (emit_ui_log, emit_ui_status) =
|
||||||
|
kb_register_demo_ws_event_and_decide_emission(&relay_runtime, &event).await;
|
||||||
|
if emit_ui_log {
|
||||||
kb_emit_demo_ws_log(&relay_app_handle, &kb_format_demo_ws_event(&event));
|
kb_emit_demo_ws_log(&relay_app_handle, &kb_format_demo_ws_event(&event));
|
||||||
|
}
|
||||||
|
if emit_ui_status {
|
||||||
kb_emit_demo_ws_status(&relay_app_handle, &relay_runtime).await;
|
kb_emit_demo_ws_status(&relay_app_handle, &relay_runtime).await;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(tokio::sync::broadcast::error::RecvError::Lagged(skipped)) => {
|
Err(tokio::sync::broadcast::error::RecvError::Lagged(skipped)) => {
|
||||||
kb_emit_demo_ws_log(
|
kb_emit_demo_ws_log(
|
||||||
&relay_app_handle,
|
&relay_app_handle,
|
||||||
@@ -306,10 +349,7 @@ pub(crate) async fn demo_ws_disconnect(
|
|||||||
if let Some(client) = &client_option {
|
if let Some(client) = &client_option {
|
||||||
let disconnect_result = client.disconnect().await;
|
let disconnect_result = client.disconnect().await;
|
||||||
if let Err(error) = disconnect_result {
|
if let Err(error) = disconnect_result {
|
||||||
kb_emit_demo_ws_log(
|
kb_emit_demo_ws_log(&app_handle, &format!("[demo] disconnect error: {}", error));
|
||||||
&app_handle,
|
|
||||||
&format!("[demo] disconnect error: {}", error),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(relay_task) = relay_task_option {
|
if let Some(relay_task) = relay_task_option {
|
||||||
@@ -581,11 +621,22 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn kb_apply_demo_ws_event_to_runtime(
|
async fn kb_register_demo_ws_event_and_decide_emission(
|
||||||
runtime_arc: &std::sync::Arc<tokio::sync::Mutex<KbDemoWsRuntimeState>>,
|
runtime_arc: &std::sync::Arc<tokio::sync::Mutex<KbDemoWsRuntimeState>>,
|
||||||
event: &kb_lib::WsEvent,
|
event: &kb_lib::WsEvent,
|
||||||
) {
|
) -> (bool, bool) {
|
||||||
let mut runtime_guard = runtime_arc.lock().await;
|
let mut runtime_guard = runtime_arc.lock().await;
|
||||||
|
runtime_guard.event_count_total = runtime_guard.event_count_total.saturating_add(1);
|
||||||
|
runtime_guard.last_event_kind = Some(kb_demo_ws_event_kind_name(event).to_string());
|
||||||
|
let mut emit_ui_log = true;
|
||||||
|
let force_status_emit = matches!(
|
||||||
|
event,
|
||||||
|
kb_lib::WsEvent::Connected { .. }
|
||||||
|
| kb_lib::WsEvent::Disconnected { .. }
|
||||||
|
| kb_lib::WsEvent::SubscriptionRegistered { .. }
|
||||||
|
| kb_lib::WsEvent::SubscriptionUnregistered { .. }
|
||||||
|
| kb_lib::WsEvent::Error { .. }
|
||||||
|
);
|
||||||
match event {
|
match event {
|
||||||
kb_lib::WsEvent::Connected {
|
kb_lib::WsEvent::Connected {
|
||||||
endpoint_name,
|
endpoint_name,
|
||||||
@@ -597,6 +648,35 @@ async fn kb_apply_demo_ws_event_to_runtime(
|
|||||||
}
|
}
|
||||||
kb_lib::WsEvent::SubscriptionRegistered { subscription, .. } => {
|
kb_lib::WsEvent::SubscriptionRegistered { subscription, .. } => {
|
||||||
runtime_guard.current_subscription = Some(subscription.clone());
|
runtime_guard.current_subscription = Some(subscription.clone());
|
||||||
|
runtime_guard.notification_count_total = 0;
|
||||||
|
}
|
||||||
|
kb_lib::WsEvent::SubscriptionNotification { subscription, .. } => {
|
||||||
|
runtime_guard.notification_count_total =
|
||||||
|
runtime_guard.notification_count_total.saturating_add(1);
|
||||||
|
let subscribe_method = subscription.subscribe_method.as_str();
|
||||||
|
let notif_count = runtime_guard.notification_count_total;
|
||||||
|
if subscribe_method == "logsSubscribe" || subscribe_method == "programSubscribe" {
|
||||||
|
emit_ui_log = notif_count % 100 == 1;
|
||||||
|
} else if subscribe_method == "slotsUpdatesSubscribe" {
|
||||||
|
emit_ui_log = notif_count % 20 == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kb_lib::WsEvent::TextMessage { .. } | kb_lib::WsEvent::JsonRpcMessage { .. } => {
|
||||||
|
let subscribe_method_option = runtime_guard
|
||||||
|
.current_subscription
|
||||||
|
.as_ref()
|
||||||
|
.map(|subscription| subscription.subscribe_method.as_str());
|
||||||
|
if let Some(subscribe_method) = subscribe_method_option {
|
||||||
|
if subscribe_method == "logsSubscribe"
|
||||||
|
|| subscribe_method == "programSubscribe"
|
||||||
|
|| subscribe_method == "slotsUpdatesSubscribe"
|
||||||
|
{
|
||||||
|
emit_ui_log = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kb_lib::WsEvent::Pong { .. } => {
|
||||||
|
emit_ui_log = false;
|
||||||
}
|
}
|
||||||
kb_lib::WsEvent::SubscriptionUnregistered {
|
kb_lib::WsEvent::SubscriptionUnregistered {
|
||||||
subscription_id, ..
|
subscription_id, ..
|
||||||
@@ -605,9 +685,9 @@ async fn kb_apply_demo_ws_event_to_runtime(
|
|||||||
.current_subscription
|
.current_subscription
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|subscription| subscription.subscription_id);
|
.map(|subscription| subscription.subscription_id);
|
||||||
|
|
||||||
if current_subscription_id == Some(*subscription_id) {
|
if current_subscription_id == Some(*subscription_id) {
|
||||||
runtime_guard.current_subscription = None;
|
runtime_guard.current_subscription = None;
|
||||||
|
runtime_guard.notification_count_total = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kb_lib::WsEvent::Disconnected { .. } => {
|
kb_lib::WsEvent::Disconnected { .. } => {
|
||||||
@@ -616,9 +696,30 @@ async fn kb_apply_demo_ws_event_to_runtime(
|
|||||||
runtime_guard.keepalive_task = None;
|
runtime_guard.keepalive_task = None;
|
||||||
runtime_guard.connection_state = kb_lib::KbConnectionState::Disconnected;
|
runtime_guard.connection_state = kb_lib::KbConnectionState::Disconnected;
|
||||||
runtime_guard.current_subscription = None;
|
runtime_guard.current_subscription = None;
|
||||||
|
runtime_guard.notification_count_total = 0;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
if emit_ui_log {
|
||||||
|
runtime_guard.ui_log_count = runtime_guard.ui_log_count.saturating_add(1);
|
||||||
|
} else {
|
||||||
|
runtime_guard.suppressed_log_count = runtime_guard.suppressed_log_count.saturating_add(1);
|
||||||
|
}
|
||||||
|
let now = std::time::Instant::now();
|
||||||
|
let emit_ui_status = if force_status_emit {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
match runtime_guard.last_status_emit_at {
|
||||||
|
Some(last_status_emit_at) => {
|
||||||
|
now.duration_since(last_status_emit_at) >= std::time::Duration::from_millis(250)
|
||||||
|
}
|
||||||
|
None => true,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if emit_ui_status {
|
||||||
|
runtime_guard.last_status_emit_at = Some(now);
|
||||||
|
}
|
||||||
|
(emit_ui_log, emit_ui_status)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn kb_emit_demo_ws_status(
|
async fn kb_emit_demo_ws_status(
|
||||||
@@ -846,3 +947,22 @@ async fn kb_demo_ws_keepalive_loop(app_handle: &tauri::AppHandle, client: &kb_li
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn kb_demo_ws_event_kind_name(event: &kb_lib::WsEvent) -> &'static str {
|
||||||
|
match event {
|
||||||
|
kb_lib::WsEvent::Connected { .. } => "connected",
|
||||||
|
kb_lib::WsEvent::TextMessage { .. } => "text_message",
|
||||||
|
kb_lib::WsEvent::JsonRpcMessage { .. } => "json_rpc_message",
|
||||||
|
kb_lib::WsEvent::JsonRpcParseError { .. } => "json_rpc_parse_error",
|
||||||
|
kb_lib::WsEvent::SubscriptionRegistered { .. } => "subscription_registered",
|
||||||
|
kb_lib::WsEvent::SubscriptionNotification { .. } => "subscription_notification",
|
||||||
|
kb_lib::WsEvent::JsonRpcNotificationWithoutSubscription { .. } => "untracked_notification",
|
||||||
|
kb_lib::WsEvent::SubscriptionUnregistered { .. } => "subscription_unregistered",
|
||||||
|
kb_lib::WsEvent::BinaryMessage { .. } => "binary_message",
|
||||||
|
kb_lib::WsEvent::Ping { .. } => "ping",
|
||||||
|
kb_lib::WsEvent::Pong { .. } => "pong",
|
||||||
|
kb_lib::WsEvent::CloseReceived { .. } => "close_received",
|
||||||
|
kb_lib::WsEvent::Disconnected { .. } => "disconnected",
|
||||||
|
kb_lib::WsEvent::Error { .. } => "error",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "kb-bapp",
|
"productName": "kb-bapp",
|
||||||
"version": "0.3.0",
|
"version": "0.3.5",
|
||||||
"identifier": "com.sasedev.kb-app",
|
"identifier": "com.sasedev.kb-app",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user