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