1#![allow(clippy::missing_safety_doc)]
5
6pub use uhlc;
7
8pub mod common;
9pub mod config;
10pub mod descriptor;
11pub mod id;
12pub mod metadata;
13
14pub mod coordinator_to_daemon;
15pub mod daemon_to_coordinator;
16
17pub mod daemon_to_daemon;
18
19pub mod daemon_to_node;
20pub mod node_to_daemon;
21
22pub mod cli_to_coordinator;
23pub mod coordinator_to_cli;
24
25pub mod integration_testing_format;
26
27pub use arrow_data;
28pub use arrow_schema;
29use uuid::{Timestamp, Uuid};
30
31pub type DataflowId = uuid::Uuid;
35
36#[derive(
37 Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash,
38)]
39pub struct SessionId(uuid::Uuid);
40
41impl SessionId {
42 pub fn generate() -> Self {
43 Self(Uuid::new_v7(Timestamp::now(uuid::NoContext)))
44 }
45
46 pub fn uuid(&self) -> uuid::Uuid {
47 self.0
48 }
49}
50
51#[derive(
52 Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash,
53)]
54pub struct BuildId(uuid::Uuid);
55
56impl BuildId {
57 pub fn generate() -> Self {
58 Self(Uuid::new_v7(Timestamp::now(uuid::NoContext)))
59 }
60}
61
62impl std::fmt::Display for BuildId {
63 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
64 write!(f, "BuildId({})", self.0)
65 }
66}
67
68fn current_crate_version() -> semver::Version {
69 let crate_version_raw = env!("CARGO_PKG_VERSION");
70
71 semver::Version::parse(crate_version_raw).unwrap()
72}
73
74fn versions_compatible(
75 crate_version: &semver::Version,
76 specified_version: &semver::Version,
77) -> Result<bool, String> {
78 let req = semver::VersionReq::parse(&crate_version.to_string()).map_err(|error| {
79 format!("failed to parse crate version `{crate_version}` as `VersionReq`: {error}")
80 })?;
81 let specified_dora_req = semver::VersionReq::parse(&specified_version.to_string())
82 .map_err(|error| {
83 format!(
84 "failed to parse specified dora version `{specified_version}` as `VersionReq`: {error}",
85 )
86 })?;
87 let matches = req.matches(specified_version) || specified_dora_req.matches(crate_version);
88 Ok(matches)
89}