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;
43
44pub use diagnostics::{
45    DiagnosticAdmission, DiagnosticEvent, DiagnosticFilter, DiagnosticObserver, DiagnosticOutcome,
46    DiagnosticRecord, DiagnosticShutdownOutcome, DiagnosticSource, DiagnosticSubscribeError,
47    RuntimeDiagnostics, RuntimeFailureKind, RuntimeInvocationProbe,
48};
49pub use event::{
50    EventAdmission, EventCapability, EventPublishResult, EventPublishStatus, NativeEventEndpoint,
51    NativeEventHandle, PluginEventDependencyHandle,
52};
53pub use invocation::*;
54pub use stream::{
55    NativeStream, NativeStreamEndpoint, NativeStreamHandle, NativeStreamItem, NativeStreamSession,
56    StreamCapability, StreamEvent, StreamSession,
57};
58
59type ErasedValue = Box<dyn Any>;
60type ErasedDomainResult = Result<ErasedValue, ErasedValue>;
61type NativeBindingTable = BTreeMap<(String, &'static str), Vec<NativeEndpointBinding>>;
62type NativeEndpointStateTable = BTreeMap<(String, String), Rc<NativeEndpointState>>;
63type NativeStreamBindingTable = BTreeMap<(String, &'static str), Vec<NativeStreamEndpointBinding>>;
64type NativeStreamEndpointStateTable = BTreeMap<(String, String), Rc<NativeStreamEndpointState>>;
65type NativeEventBindingTable =
66    BTreeMap<(String, &'static str), Vec<event::NativeEventEndpointBinding>>;
67type NativeEventEndpointStateTable =
68    BTreeMap<(String, String), Rc<event::NativeEventEndpointState>>;
69
70/// Static identity and Rust value types generated for one request Capability.
71pub use deterministic::*;
72pub use driver::*;
73pub use kernel::*;
74pub use lifecycle::*;
75pub use prepared::*;
76pub use request::*;
77pub use request_handle::*;
78pub use runtime::*;
79use supervision::{
80    begin_plugin_supervision, deactivate_in_reverse, plugin_supervision,
81    schedule_plugin_supervision, shutdown_native_plugins, validate_native_endpoint_set,
82};