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, postcard_product,
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};
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
91/* === Re-Exports === */
92
93pub use harmos_domain::model;
94pub use harmos_operations as builtins;
95
96pub use application::Application;
97pub use error::{BackendFailure, Error};
98pub use harmos_domain::{DefinitionId, Identified};
99
100#[cfg(feature = "signal")]
101pub use harmos_storage::signal;
102
103pub use harmos_domain::{
104    Backoff, Digest, Fingerprint, Jitter, OperationDeclaration, OperationDefinition, OperationPolicy, Portable, QualifiedId, RestartPolicy,
105    RetryPolicy, ServicePolicy,
106};
107pub use harmos_sdk::operations::{EndpointSet, Response};
108pub use harmos_sdk::{
109    Context, Dependencies, Dependent, Executable, ExecutionContext, Operation, RegistrationBatch, Resource, ResourceError, Service,
110};
111pub use operations::refusal::Refusal;
112pub use operations::{Invocation, Lane, Registration, RegistrationExt, Running};
113pub use runtime::{Builder, Handle, Runtime};
114pub use services::{ServiceContext, ServiceManager};
115
116pub use harmos_domain::{
117    Aggregate, Failure, Identifier, IdentifierError, MemorySize, Message, MessageError, Metadata, RowMetadata, Storable, StreamField,
118    StreamSpec, Value, ValueError, btree_map_memory,
119};
120pub use harmos_sdk::plugin::Plugin;
121// Contract Namespaces The Host Does Not Extend, Re-Exported Whole.
122
123// `message` Names Both The Contract Module And Its Same-Named Attribute.
124pub use harmos_domain::{artifacts, catalog, failure, listeners, message, schema};
125pub use harmos_macros::{lanes, listener, observer, operation, plugin, record, records, stream, streams, transaction, transactions};
126
127/* === Imports === */
128
129// Standard Library Imports
130
131// Third Party Imports
132extern crate self as harmos;
133extern crate self as harmos_runtime;
134// Local Imports
135
136/* === Constants === */
137
138/* === Macros === */
139
140/* === Type Aliases === */
141
142pub type Result<T, E = std::convert::Infallible> = std::result::Result<T, Error<E>>;
143
144/* === Structs === */
145
146/* === Enums === */
147
148/* === Traits === */
149
150/* === Implementations === */
151
152/* === Public Functions === */
153
154/* === Private Functions === */
155
156/* === Tests === */