Skip to main content

platform_core/
lib.rs

1//
2// Copyright 2018-2026 Accenture Technology
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17//! # platform-core (Rust port)
18//!
19//! Rust port of mercury-composable's `platform-core` — the event-driven
20//! foundation layer. Canonical behavior spec: the Java project
21//! (`system/platform-core`, v4.8.6) — see `draft-design-specs/platform-core-port.md`.
22//!
23//! **Increment 1 — configuration management:** the `resources/` folder
24//! convention, [`MultiLevelMap`] composite keys, [`ConfigReader`] with `${...}`
25//! substitution, and the [`AppConfigReader`] base-config singleton.
26//!
27//! **Increment 2 — event-bus foundation:** the immutable [`EventEnvelope`],
28//! the [`ComposableFunction`] contract (+ [`TypedFunction`]/[`TypedAdapter`]),
29//! the [`Platform`] registry with per-route worker pools, and the
30//! [`PostOffice`] messaging client (send + RPC). Functions are addressed only
31//! by route name and never call each other directly.
32
33pub mod actuator;
34pub mod app_starter;
35pub mod automation;
36pub mod envelope;
37pub mod event_stream;
38pub mod function;
39pub mod graph;
40pub(crate) mod inbox;
41pub mod logging;
42pub mod platform;
43pub mod post_office;
44mod preload_override;
45pub mod registry;
46pub mod serializer;
47pub mod telemetry;
48pub mod trace;
49pub mod util;
50
51pub use app_starter::{AppStarter, AutoStart, EntryPoint};
52// the annotation layer (Java @PreLoad/@BeforeApplication/@MainApplication/@ZeroTracing)
53pub use platform_macros::{
54    before_application, event_interceptor, main_application, optional_service, preload,
55    websocket_service, zero_tracing,
56};
57// re-exported so the macros' generated `submit!` resolves without the user
58// adding `inventory` as a direct dependency
59pub use inventory;
60
61/// Generate the application `main()` — the Java `AutoStart.main(args)`
62/// one-liner. Expands **in the application crate**, so the app's own
63/// `resources/` folder (next to its `Cargo.toml`) joins the resource roots:
64///
65/// ```ignore
66/// platform_core::auto_start_main!();
67/// ```
68#[macro_export]
69macro_rules! auto_start_main {
70    () => {
71        fn main() -> ::core::result::Result<(), $crate::AppError> {
72            // the application's own resources/ folder (compile-time path of
73            // the invoking crate)
74            $crate::resources::prepend_resource_root(concat!(
75                env!("CARGO_MANIFEST_DIR"),
76                "/resources"
77            ));
78            $crate::AutoStart::run()
79        }
80    };
81}
82pub use envelope::EventEnvelope;
83pub use event_stream::EventStreamWriter;
84pub use function::{AppError, ComposableFunction, TypedAdapter, TypedFunction};
85pub use graph::{MiniGraph, SimpleConnection, SimpleNode, SimpleRelationship};
86pub use platform::{FunctionOptions, Platform};
87pub use post_office::PostOffice;
88pub use util::app_config_reader::AppConfigReader;
89pub use util::config_reader::{ConfigError, ConfigReader};
90pub use util::managed_cache::{CacheValue, ManagedCache};
91pub use util::multi_level_map::{ConfigValue, MultiLevelMap};
92pub use util::{overrides, resources};