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, PlanResolutionError, PluginCriticality,
23    RequestAdmissionPlan, ResolvedAppPlan, RestartMode, RestartPolicy,
24};
25
26mod cleanup;
27mod deterministic;
28mod diagnostics;
29mod driver;
30mod event;
31mod invocation;
32mod kernel;
33mod lifecycle;
34mod prepared;
35mod request;
36mod request_handle;
37mod runtime;
38mod settlement;
39pub use settlement::ExecutionLease;
40mod startup;
41mod stream;
42mod supervision;
43mod transition;
44pub use transition::{TransitionOutcome, TransitionRetirement, TransitionStatus};
45
46pub use diagnostics::{
47    DiagnosticAdmission, DiagnosticEvent, DiagnosticFilter, DiagnosticObserver, DiagnosticOutcome,
48    DiagnosticRecord, DiagnosticShutdownOutcome, DiagnosticSource, DiagnosticSubscribeError,
49    RuntimeDiagnostics, RuntimeFailureKind, RuntimeInvocationProbe,
50};
51pub use event::{
52    EventAdmission, EventCapability, EventPublishResult, EventPublishStatus, NativeEventEndpoint,
53    NativeEventHandle, PluginEventDependencyHandle,
54};
55pub use invocation::*;
56pub use stream::{
57    NativeStream, NativeStreamEndpoint, NativeStreamHandle, NativeStreamItem, NativeStreamSession,
58    StreamCapability, StreamEvent, StreamSession,
59};
60
61type ErasedValue = Box<dyn Any>;
62type ErasedDomainResult = Result<ErasedValue, ErasedValue>;
63type NativeBindingTable = BTreeMap<(String, &'static str), Vec<NativeEndpointBinding>>;
64type NativeEndpointStateTable = BTreeMap<(String, String), Rc<NativeEndpointState>>;
65type NativeStreamBindingTable = BTreeMap<(String, &'static str), Vec<NativeStreamEndpointBinding>>;
66type NativeStreamEndpointStateTable = BTreeMap<(String, String), Rc<NativeStreamEndpointState>>;
67type NativeEventBindingTable =
68    BTreeMap<(String, &'static str), Vec<event::NativeEventEndpointBinding>>;
69type NativeEventEndpointStateTable =
70    BTreeMap<(String, String), Rc<event::NativeEventEndpointState>>;
71
72/// Static identity and Rust value types generated for one request Capability.
73pub use deterministic::*;
74pub use driver::*;
75pub use kernel::*;
76pub use lifecycle::*;
77pub use prepared::*;
78pub use request::*;
79pub use request_handle::*;
80pub use runtime::*;
81use supervision::{
82    begin_plugin_supervision, deactivate_in_reverse, plugin_supervision,
83    schedule_plugin_supervision, shutdown_native_plugins, validate_native_endpoint_set,
84};