Skip to main content

lenso_kernel/
lib.rs

1//! Portable Lenso vNext Kernel and Runtime Driver seam.
2
3use std::{
4    any::Any,
5    cell::{Cell, RefCell},
6    collections::{BTreeMap, BTreeSet, VecDeque},
7    future::Future,
8    panic::AssertUnwindSafe,
9    pin::Pin,
10    rc::{Rc, Weak},
11    task::{Context, Poll},
12    time::Duration,
13};
14
15use futures::{
16    channel::oneshot,
17    executor::{LocalPool, LocalSpawner},
18    future::{AbortHandle, Abortable, Either, FutureExt, LocalBoxFuture, pending, select},
19    task::{LocalSpawnExt, SpawnError},
20};
21use lenso_app_plan::{
22    EventAdmissionPlan, ExecutionClassId, ModuleCriticality, PlanResolutionError,
23    RequestAdmissionPlan, ResolvedAppPlan, RestartMode, RestartPolicy,
24};
25
26mod deterministic;
27mod diagnostics;
28mod driver;
29mod event;
30mod invocation;
31mod kernel;
32mod lifecycle;
33mod prepared;
34mod request;
35mod request_handle;
36mod runtime;
37mod stream;
38mod supervision;
39
40pub use diagnostics::{
41    DiagnosticAdmission, DiagnosticEvent, DiagnosticFilter, DiagnosticObserver, DiagnosticOutcome,
42    DiagnosticRecord, DiagnosticShutdownOutcome, DiagnosticSource, DiagnosticSubscribeError,
43    RuntimeDiagnostics, RuntimeFailureKind,
44};
45pub use event::{
46    EventAdmission, EventCapability, EventPublishResult, EventPublishStatus,
47    ModuleEventDependencyHandle, NativeEventEndpoint, NativeEventHandle,
48};
49pub use invocation::*;
50pub use stream::{
51    NativeStream, NativeStreamEndpoint, NativeStreamHandle, NativeStreamItem, NativeStreamSession,
52    StreamCapability, StreamEvent, StreamSession,
53};
54
55type ErasedValue = Box<dyn Any>;
56type ErasedDomainResult = Result<ErasedValue, ErasedValue>;
57type NativeBindingTable = BTreeMap<(String, &'static str), Vec<NativeEndpointBinding>>;
58type NativeEndpointStateTable = BTreeMap<(String, String), Rc<NativeEndpointState>>;
59type NativeStreamBindingTable = BTreeMap<(String, &'static str), Vec<NativeStreamEndpointBinding>>;
60type NativeStreamEndpointStateTable = BTreeMap<(String, String), Rc<NativeStreamEndpointState>>;
61type NativeEventBindingTable =
62    BTreeMap<(String, &'static str), Vec<event::NativeEventEndpointBinding>>;
63type NativeEventEndpointStateTable =
64    BTreeMap<(String, String), Rc<event::NativeEventEndpointState>>;
65
66/// Static identity and Rust value types generated for one request Capability.
67pub use deterministic::*;
68pub use driver::*;
69pub use kernel::*;
70pub use lifecycle::*;
71pub use prepared::*;
72pub use request::*;
73pub use request_handle::*;
74pub use runtime::*;
75use supervision::{
76    begin_module_supervision, deactivate_in_reverse, module_supervision,
77    schedule_module_supervision, shutdown_native_modules, validate_native_endpoint_set,
78};