Skip to content

Commit 1ac7cde

Browse files
authored
[ntp-admin-types] reorganize per RFD 619 (#9528)
1 parent 79b29e0 commit 1ac7cde

File tree

13 files changed

+124
-43
lines changed

13 files changed

+124
-43
lines changed

Cargo.lock

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ members = [
109109
"ntp-admin",
110110
"ntp-admin/api",
111111
"ntp-admin/types",
112+
"ntp-admin/types/versions",
112113
"oximeter/api",
113114
"oximeter/collector",
114115
"oximeter/db",
@@ -274,6 +275,7 @@ default-members = [
274275
"ntp-admin",
275276
"ntp-admin/api",
276277
"ntp-admin/types",
278+
"ntp-admin/types/versions",
277279
"oximeter/api",
278280
"oximeter/collector",
279281
"oximeter/db",
@@ -546,6 +548,7 @@ newtype_derive = "0.1.6"
546548
ntp-admin-api = { path = "ntp-admin/api" }
547549
ntp-admin-client = { path = "clients/ntp-admin-client" }
548550
ntp-admin-types = { path = "ntp-admin/types" }
551+
ntp-admin-types-versions = { path = "ntp-admin/types/versions" }
549552
mg-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "0df320d42b356e689a3c7a7600eec9b16770237a" }
550553
ddm-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "0df320d42b356e689a3c7a7600eec9b16770237a" }
551554
multimap = "0.10.1"

ntp-admin/api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ workspace = true
1111
dropshot.workspace = true
1212
dropshot-api-manager-types.workspace = true
1313
http.workspace = true
14-
ntp-admin-types.workspace = true
14+
ntp-admin-types-versions.workspace = true
1515
omicron-common.workspace = true
1616
omicron-uuid-kinds.workspace = true
1717
omicron-workspace-hack.workspace = true

ntp-admin/api/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use dropshot::{HttpError, HttpResponseOk, RequestContext};
66
use dropshot_api_manager_types::api_versions;
7+
use ntp_admin_types_versions::latest;
78

89
api_versions!([
910
// WHEN CHANGING THE API (part 1 of 2):
@@ -43,5 +44,5 @@ pub trait NtpAdminApi {
4344
}]
4445
async fn timesync(
4546
rqctx: RequestContext<Self::Context>,
46-
) -> Result<HttpResponseOk<ntp_admin_types::TimeSync>, HttpError>;
47+
) -> Result<HttpResponseOk<latest::timesync::TimeSync>, HttpError>;
4748
}

ntp-admin/src/http_entrypoints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use dropshot::HttpError;
77
use dropshot::HttpResponseOk;
88
use dropshot::RequestContext;
99
use ntp_admin_api::*;
10-
use ntp_admin_types::TimeSync;
10+
use ntp_admin_types::timesync::TimeSync;
1111
use slog::info;
1212
use slog_error_chain::InlineErrorChain;
1313
use std::net::IpAddr;

ntp-admin/types/Cargo.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,5 @@ license = "MPL-2.0"
88
workspace = true
99

1010
[dependencies]
11-
chrono.workspace = true
12-
omicron-common.workspace = true
11+
ntp-admin-types-versions.workspace = true
1312
omicron-workspace-hack.workspace = true
14-
schemars.workspace = true
15-
serde.workspace = true
16-
thiserror.workspace = true
17-
18-
[dev-dependencies]
19-
proptest.workspace = true
20-
test-strategy.workspace = true

ntp-admin/types/src/lib.rs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,13 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
use std::net::IpAddr;
5+
//! Common types for the NTP Admin API.
6+
//!
7+
//! This crate re-exports the latest versions of all types from the
8+
//! `ntp-admin-types-versions` crate. These are floating identifiers that should
9+
//! be used by business logic that doesn't need to care about API versioning.
10+
//!
11+
//! The API crate (`ntp-admin-api`) uses fixed identifiers from the versions
12+
//! crate directly.
613
7-
use schemars::JsonSchema;
8-
use serde::{Deserialize, Serialize};
9-
10-
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
11-
pub struct TimeSync {
12-
/// The synchronization state of the sled, true when the system clock
13-
/// and the NTP clock are in sync (to within a small window).
14-
pub sync: bool,
15-
/// The NTP reference ID.
16-
pub ref_id: u32,
17-
/// The NTP reference IP address.
18-
pub ip_addr: IpAddr,
19-
/// The NTP stratum (our upstream's stratum plus one).
20-
pub stratum: u8,
21-
/// The NTP reference time (i.e. what chrony thinks the current time is, not
22-
/// necessarily the current system time).
23-
pub ref_time: f64,
24-
// This could be f32, but there is a problem with progenitor/typify
25-
// where, although the f32 correctly becomes "float" (and not "double") in
26-
// the API spec, that "float" gets converted back to f64 when generating
27-
// the client.
28-
/// The current offset between the NTP clock and system clock.
29-
pub correction: f64,
30-
}
14+
pub mod timesync;

ntp-admin/types/src/timesync.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
pub use ntp_admin_types_versions::latest::timesync::*;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "ntp-admin-types-versions"
3+
version = "0.1.0"
4+
edition.workspace = true
5+
license = "MPL-2.0"
6+
7+
[lints]
8+
workspace = true
9+
10+
[dependencies]
11+
omicron-workspace-hack.workspace = true
12+
schemars.workspace = true
13+
serde.workspace = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! Version `INITIAL` of the NTP Admin API.
6+
7+
pub mod timesync;

0 commit comments

Comments
 (0)