mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Stopped long queries, Read is_open() through TLS, Simplified answers and paging
- [server] query_time_limit (20 s by default) stops a client's query through SQLite's progress handler: refused with QueryTimedOut (11). A client closing while its query runs stops it too. - The answer timeout in the DLL (BakaShrot_SetAnswerTimeout / GetAnswerTimeout, kept across connections), Python (answer_timeout) and C# (AnswerTimeoutMs); QueryTimedOut in every binding. - is_open() reads what's waiting through TLS: a close_notify says closed, TLS's own records keep it open, unasked data or a broken stream close it. - The Rust client checks an answer's type in one place (TryFrom per packet); Client::wait() pings while waiting (the tool's --follow). - Pair::from(&Head), heads_after taking a Pair; simpler SyncState paging on both ends; the writer's redundant rollback check dropped. - codes.rs: the bindings' error codes and copied values match Rust's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ mod cert;
|
||||
|
||||
use bakashrot_client::{Client, Error, Settings};
|
||||
use bakashrot_proto::error::{code_name, is_refusal_code};
|
||||
use bakashrot_proto::limits::{KEEPALIVE_SECS, MAX_MESSAGES_PER_PACKET};
|
||||
use bakashrot_proto::limits::MAX_MESSAGES_PER_PACKET;
|
||||
use bakashrot_proto::packets::{MessageEntry, NameKind};
|
||||
use clap::{Parser, Subcommand, ValueEnum};
|
||||
use serde::Deserialize;
|
||||
@@ -266,7 +266,10 @@ fn run(config: &Path, command: Command) -> Result<(), String> {
|
||||
break;
|
||||
}
|
||||
if !batch.more {
|
||||
wait(&mut client, Duration::from_millis(interval))?;
|
||||
// Pinging meanwhile: `--interval` goes up to 1 h.
|
||||
client
|
||||
.wait(Duration::from_millis(interval))
|
||||
.map_err(failed)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,22 +320,6 @@ fn run(config: &Path, command: Command) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Waits `duration`, pinging every `KEEPALIVE_SECS` meanwhile: the server
|
||||
/// closes a connection silent for 5 min, and `--interval` goes up to 1 h.
|
||||
fn wait(client: &mut Client, duration: Duration) -> Result<(), String> {
|
||||
let keepalive = Duration::from_secs(KEEPALIVE_SECS);
|
||||
let mut left = duration;
|
||||
loop {
|
||||
let step = left.min(keepalive);
|
||||
std::thread::sleep(step);
|
||||
left -= step;
|
||||
if left.is_zero() {
|
||||
return Ok(());
|
||||
}
|
||||
client.ping().map_err(failed)?;
|
||||
}
|
||||
}
|
||||
|
||||
/// A topic and node's latest message, if any.
|
||||
fn latest(client: &mut Client, topic: &str, node: &str) -> Result<Option<MessageEntry>, String> {
|
||||
let latest = client.get_messages(topic, node, None, 1).map_err(failed)?;
|
||||
|
||||
Reference in New Issue
Block a user