Skip to main content

harmos_runtime/
lib.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12pub(crate) use harmos_storage::aggregate;
13pub mod config;
14mod error;
15pub mod filesystem;
16#[cfg(feature = "grpc")]
17pub mod grpc;
18pub mod prelude;
19pub mod storage;
20
21mod application;
22
23pub mod state;
24
25pub mod records;
26
27#[cfg(all(not(target_arch = "wasm32"), feature = "plugin"))]
28pub mod plugin;
29
30#[cfg(all(not(target_arch = "wasm32"), feature = "plugin-sidecar"))]
31pub mod sidecar;
32
33#[cfg(all(not(target_arch = "wasm32"), feature = "plugin-guest"))]
34pub mod guest;
35
36pub mod operations;
37
38pub mod runtime;
39
40#[cfg(feature = "simulation")]
41pub mod simulation;
42
43pub mod streams;
44
45pub mod services;
46
47pub mod observers;
48
49mod supervision;
50
51#[doc(hidden)]
52pub mod __private {
53    pub use harmos_domain::config::SchemaSettings;
54    pub use harmos_domain::plugin::schema_markers as PluginSchemaMarkers;
55    pub use harmos_sdk::__private::RegistrationBatch;
56    pub extern crate serde;
57    pub extern crate serde_json;
58    pub use harmos_domain::__private::CarrierContext;
59    pub use harmos_domain::__private::{
60        MapEntry, MessageError, PostcardReader, PostcardValue, decoding_add, decoding_multiply, decoding_vector, operation_identity,
61        owner_segment, postcard_product, stream_identity,
62    };
63
64    pub use harmos_domain::inventory as PluginInventory;
65    pub use harmos_domain::{Registrar as PluginRegistrar, RegistrationError as PluginRegistrationError};
66    pub use harmos_sdk::plugin::{
67        Contribution as PluginContribution, Declared as PluginDeclared, Grant as PluginGrant, Requirement as PluginRequirement,
68        Requirements as PluginRequirements,
69    };
70    #[cfg(feature = "plugin-sidecar")]
71    pub use harmos_sidecar as sidecar;
72
73    // A stream declaration is authored wherever its row type is, host core or
74    // no host core, so these three are as unconditional as the attribute that
75    // generates them.
76    pub use harmos_domain::streams::{BatchDefinition, StreamCatalog, StreamRow};
77    // How generated code names a type the tokens it was handed cannot spell.
78    // Ungated on purpose: a hand-written contribution in a crate that compiles
79    // no authoring attributes at all still resolves the same paths.
80
81    pub use crate::state::{Catalogued, Mutual, Paired};
82    pub use harmos_domain::__private::Answer;
83
84    pub fn stream_definition<S: StreamRow>(id: &'static str, version: u32, window: usize) -> crate::streams::Definition {
85        crate::streams::Definition::declared::<S>(id, version, window)
86            .batching(S::batch_definition())
87            .presentation(S::metadata(), S::row_metadata())
88    }
89}
90
91pub mod catalog {
92    pub use harmos_domain::catalog::*;
93}
94
95/* === Re-Exports === */
96
97pub use harmos_domain as domain;
98pub use harmos_domain::model;
99pub use harmos_operations as builtins;
100
101pub use application::{Application, Startup};
102pub use error::{BackendFailure, Error};
103pub use harmos_domain::{DefinitionId, Identified};
104
105#[cfg(feature = "signal")]
106pub use harmos_storage::signal;
107
108pub use harmos_domain::{
109    Backoff, Digest, Fingerprint, Jitter, OperationDeclaration, OperationDefinition, OperationPolicy, Portable, QualifiedId, RestartPolicy,
110    RetryPolicy, ServicePolicy,
111};
112pub use harmos_sdk::operations::{EndpointSet, Response};
113pub use harmos_sdk::{Context, Dependent, Executable, ExecutionContext, Lifecycle, Operation, Resource, ResourceError, Service, Setup};
114pub use operations::refusal::Refusal;
115pub use operations::{Catalog, Invocation, Lane, Running};
116pub use runtime::{Handle, Runtime, StartupError};
117pub use services::{ServiceContext, ServiceManager};
118
119pub use harmos_domain::{
120    Aggregate, Failure, Identifier, IdentifierError, MemorySize, Message, MessageError, Metadata, RowMetadata, Storable, StreamField,
121    StreamSpec, Value, ValueError, btree_map_memory,
122};
123#[cfg(feature = "plugin-sidecar")]
124pub use harmos_macros::plugin as sidecar;
125#[cfg(feature = "plugin-guest")]
126pub use harmos_macros::plugin as guest;
127pub use harmos_sdk::plugin::Plugin;
128// Contract Namespaces The Host Does Not Extend, Re-Exported Whole.
129
130// `message` Names Both The Contract Module And Its Same-Named Attribute.
131pub use harmos_domain::{artifacts, failure, listeners, message, schema};
132pub use harmos_macros::{
133    lanes, listener, observer, plugin, record, records, runtime_catalog as catalog, runtime_operation as operation, stream, streams,
134    transaction, transactions,
135};
136
137/* === Imports === */
138
139// Standard Library Imports
140
141// Third Party Imports
142extern crate self as harmos;
143extern crate self as harmos_runtime;
144// Local Imports
145
146/* === Constants === */
147
148/* === Macros === */
149
150/* === Type Aliases === */
151
152pub type Result<T, E = std::convert::Infallible> = std::result::Result<T, Error<E>>;
153
154/* === Structs === */
155
156/* === Enums === */
157
158/* === Traits === */
159
160/* === Implementations === */
161
162/* === Public Functions === */
163
164/* === Private Functions === */
165
166/* === Tests === */