Atrion Class
new Atrion(options?: AtrionOptions)| Option | Type | Default |
|---|---|---|
| engine | 'wasm' | 'js' | 'auto' | 'auto' |
| stateProvider | StateProvider | InMemoryProvider |
| bootstrapSamples | number | 100 |
| decayRate | number | 0.1 |
| scarFactor | number | 5 |
Methods
connect()
Initialize the engine and state provider. Must be called before routing.
Returns: Promise<void>
route(routeId, telemetry, options?)
Make a routing decision based on current system state.
routeId: string — Unique route identifier
telemetry: Telemetry — Current system metrics
options?: RouteOptions — Profile, priority
Returns: Decision
startTask(taskId, options)
Acquire a lease for long-running tasks (HEAVY/EXTREME profiles).
taskId: string — Unique task identifier
options: TaskOptions — Profile, AbortController
Returns: Promise<Lease>
disconnect()
Gracefully shutdown the engine and release resources.
Returns: Promise<void>
Types
interface Telemetry { latencyMs: number errorRate: number saturation: number}
interface Decision { allow: boolean resistance: number mode: 'BOOTSTRAP' | 'OPERATIONAL' | 'CIRCUIT_BREAKER' reason?: string retryAfterMs?: number}
type Profile = 'LIGHT' | 'STANDARD' | 'HEAVY' | 'EXTREME'
interface Lease { heartbeat(status: { progress: number }): void release(): Promise<void>}Rust Crate
For direct Rust usage, see the crate documentation:
docs.rs/atrion-core