pub struct Router { /* private fields */ }Expand description
Tiny Dancer neural router
Implementations§
Source§impl Router
impl Router
pub fn into_reference(val: Router, env: Env) -> Result<Reference<Router>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<Router>>
Source§impl Router
impl Router
Sourcepub fn new(config: RouterConfig) -> Result<Self>
pub fn new(config: RouterConfig) -> Result<Self>
Create a new router with configuration
§Example
const router = new Router({
modelPath: './models/fastgrnn.safetensors',
confidenceThreshold: 0.85,
maxUncertainty: 0.15,
enableCircuitBreaker: true
});Sourcepub async fn route(&self, request: RoutingRequest) -> Result<RoutingResponse>
pub async fn route(&self, request: RoutingRequest) -> Result<RoutingResponse>
Route a request through the neural routing system
Returns routing decisions with confidence scores and model recommendations
§Example
const response = await router.route({
queryEmbedding: new Float32Array([0.1, 0.2, ...]),
candidates: [
{ id: '1', embedding: new Float32Array([...]) },
{ id: '2', embedding: new Float32Array([...]) }
]
});
console.log('Top decision:', response.decisions[0]);
console.log('Inference time:', response.inferenceTimeUs, 'μs');Sourcepub async fn reload_model(&self) -> Result<()>
pub async fn reload_model(&self) -> Result<()>
Sourcepub fn circuit_breaker_status(&self) -> Option<bool>
pub fn circuit_breaker_status(&self) -> Option<bool>
Check circuit breaker status
Returns true if the circuit is closed (healthy), false if open (unhealthy)
§Example
const isHealthy = router.circuitBreakerStatus();Trait Implementations§
Source§impl FromNapiMutRef for Router
impl FromNapiMutRef for Router
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for Router
impl FromNapiRef for Router
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &Router
impl FromNapiValue for &Router
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut Router
impl FromNapiValue for &mut Router
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ToNapiValue for Router
impl ToNapiValue for Router
Source§unsafe fn to_napi_value(env: napi_env, val: Router) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: Router) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &Router
impl ValidateNapiValue for &Router
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut Router
impl ValidateNapiValue for &mut Router
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for Router
impl !RefUnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl !UnwindSafe for Router
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more