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