route work
This commit is contained in:
parent
dc1a27c0a0
commit
ee30f19ecf
17
veilid-core/src/rpc_processor/coders/sequencing.rs
Normal file
17
veilid-core/src/rpc_processor/coders/sequencing.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub fn encode_sequencing(sequencing: Sequencing) -> veilid_capnp::Sequencing {
|
||||||
|
match sequencing {
|
||||||
|
Sequencing::NoPreference => veilid_capnp::Sequencing::NoPreference,
|
||||||
|
Sequencing::PreferOrdered => veilid_capnp::Sequencing::PreferOrdered,
|
||||||
|
Sequencing::EnsureOrdered => veilid_capnp::Sequencing::EnsureOrdered,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn decode_sequencing(sequencing: veilid_capnp::Sequencing) -> Sequencing {
|
||||||
|
match sequencing {
|
||||||
|
veilid_capnp::Sequencing::NoPreference => Sequencing::NoPreference,
|
||||||
|
veilid_capnp::Sequencing::PreferOrdered => Sequencing::PreferOrdered,
|
||||||
|
veilid_capnp::Sequencing::EnsureOrdered => Sequencing::EnsureOrdered,
|
||||||
|
}
|
||||||
|
}
|
@ -121,7 +121,7 @@ where
|
|||||||
Ok(res
|
Ok(res
|
||||||
.on_timeout(|| {
|
.on_timeout(|| {
|
||||||
log_rpc!(debug "op wait timed out: {}", handle.op_id);
|
log_rpc!(debug "op wait timed out: {}", handle.op_id);
|
||||||
log_rpc!(debug "backtrace: {}", debug_backtrace());
|
debug_print_backtrace();
|
||||||
self.cancel_op_waiter(handle.op_id);
|
self.cancel_op_waiter(handle.op_id);
|
||||||
})
|
})
|
||||||
.map(|res| {
|
.map(|res| {
|
||||||
|
@ -303,3 +303,28 @@ pub fn debug_backtrace() -> String {
|
|||||||
let bt = backtrace::Backtrace::new();
|
let bt = backtrace::Backtrace::new();
|
||||||
format!("{:?}", bt)
|
format!("{:?}", bt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn debug_print_backtrace() {
|
||||||
|
if is_debug_backtrace_enabled() {
|
||||||
|
debug!("{}", debug_backtrace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_debug_backtrace_enabled() -> bool {
|
||||||
|
cfg_if! {
|
||||||
|
if #[cfg(debug_assertions)] {
|
||||||
|
cfg_if! {
|
||||||
|
if #[cfg(target_arch = "wasm32")] {
|
||||||
|
let rbenv = get_wasm_global_string_value("RUST_BACKTRACE").unwrap_or_default();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let rbenv = std::env::var("RUST_BACKTRACE").unwrap_or_default();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rbenv == "1" || rbenv == "full"
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@ pub fn is_browser() -> bool {
|
|||||||
return cache != 0;
|
return cache != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = Reflect::has(&global().as_ref(), &"window".into()).unwrap_or_default();
|
let res = Reflect::has(&global().as_ref(), &"navigator".into()).unwrap_or_default();
|
||||||
|
|
||||||
CACHE.store(res as i8, Ordering::Relaxed);
|
CACHE.store(res as i8, Ordering::Relaxed);
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ pub fn is_browser_https() -> bool {
|
|||||||
return cache != 0;
|
return cache != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = js_sys::eval("window.location.protocol === 'https'")
|
let res = js_sys::eval("self.location.protocol === 'https'")
|
||||||
.map(|res| res.is_truthy())
|
.map(|res| res.is_truthy())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
@ -44,6 +44,13 @@ pub fn is_browser_https() -> bool {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_wasm_global_string_value<K: AsRef<str>>(key: K) -> Option<String> {
|
||||||
|
let Ok(v) = Reflect::get(&global().as_ref(), &JsValue::from_str(key.as_ref())) else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
v.as_string()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(ThisError, Debug, Clone, Eq, PartialEq)]
|
#[derive(ThisError, Debug, Clone, Eq, PartialEq)]
|
||||||
#[error("JsValue error")]
|
#[error("JsValue error")]
|
||||||
pub struct JsValueError(String);
|
pub struct JsValueError(String);
|
||||||
|
Loading…
Reference in New Issue
Block a user