zenoh_flow/
lib.rs

1//
2// Copyright (c) 2021 - 2023 ZettaScale Technology
3//
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7// which is available at https://www.apache.org/licenses/LICENSE-2.0.
8//
9// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10//
11// Contributors:
12//   ZettaScale Zenoh Team, <zenoh@zettascale.tech>
13//
14
15//!
16//! Zenoh Flow provides a zenoh-based data flow programming framework for
17//! computations that span from the cloud to the device.
18//!
19//! Zenoh Flow allows users to declare a data flow graph, via a YAML file,
20//! and uses tags to express location affinity and requirements for the
21//! operators that makeup the graph. When deploying the data flow graph,
22//! Zenoh Flow automatically deals with distribution by linking
23//! remote operators through zenoh.
24//!
25//! A data flow is composed of set of nodes: sources — producing data, operators
26//! — computing over the data, and sinks — consuming the resulting data.
27//!  These nodes are dynamically loaded at runtime.
28//!
29//! Remote source, operators, and sinks leverage zenoh to communicate in a
30//! transparent manner. In other terms, the data flow the data flow graph retails
31//! location transparency and could be deployed in
32//! different ways depending on specific needs.
33//!
34//! Zenoh Flow provides several working examples that illustrate how to
35//! define operators, sources and sinks as well as how to
36//! declaratively define they data flow graph by means of a YAML file.
37use const_format::formatcp;
38
39pub use ::zenoh_flow_derive;
40
41pub mod io;
42pub mod model;
43pub mod runtime;
44pub mod traits;
45pub mod types;
46
47pub mod utils;
48pub mod zfresult;
49
50pub use anyhow::anyhow;
51pub use zfresult::{DaemonResult, ZFResult as Result};
52
53pub mod prelude {
54    pub use crate::io::{Input, InputRaw, Inputs, Output, OutputRaw, Outputs};
55    pub use crate::traits::{Node, Operator, SendSyncAny, Sink, Source};
56    pub use crate::types::{
57        Configuration, Context, Data, DataMessage, Message, NodeId, PortId, RuntimeId,
58    };
59    pub use crate::zenoh_flow_derive::{export_operator, export_sink, export_source};
60    pub use crate::zferror;
61    pub use crate::zfresult::{Error, ErrorKind, ZFResult as Result};
62}
63
64/// Commit id of latest commit on Zenoh Flow
65pub const GIT_VERSION: &str = git_version::git_version!(prefix = "v", cargo_prefix = "v");
66
67/// Version of Zenoh Flow Cargo Package
68/// This is used to verify compatibility in nodes dynamic loading.
69pub const VERSION: &str = env!("CARGO_PKG_VERSION");
70
71/// Complete string with the Zenoh Flow version, including commit id.
72pub const FULL_VERSION: &str = formatcp!("{}-{}", VERSION, GIT_VERSION);
73
74/// Default Shared Memory size (10MiB).
75pub static DEFAULT_SHM_ELEMENT_SIZE: u64 = 10_485_760;
76
77/// Default Shared Memory elements (10).
78pub static DEFAULT_SHM_TOTAL_ELEMENTS: u64 = 10;
79
80/// Default Shared allocation backoff time (100ms)
81pub static DEFAULT_SHM_ALLOCATION_BACKOFF_NS: u64 = 100_000_000;
82
83/// Default Shared memory usage (false)
84pub static DEFAULT_USE_SHM: bool = false;