Skip to content

Commit

Permalink
decouple scuba_sample
Browse files Browse the repository at this point in the history
Summary:
Decouple scuba_sample in such a way that the sample struct definition is a separate library.
Required to minimize dependencies for the following commits.

Reviewed By: mitrandir77

Differential Revision: D66096858

fbshipit-source-id: 743a4f0c48095dc28a5f8775d10d968b6103452b
  • Loading branch information
Roman0719 authored and facebook-github-bot committed Nov 26, 2024
1 parent df4559c commit 63c543b
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ members = [
"shed/perthread",
"shed/quickcheck_arbitrary_derive",
"shed/scuba_sample",
"shed/scuba_sample/builder",
"shed/scuba_sample/client",
"shed/scuba_sample/derive",
"shed/scuba_sample/derive_tests",
"shed/scuba_stub",
Expand Down
39 changes: 37 additions & 2 deletions shed/scuba_sample/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rust_library(
autocargo = {
"cargo_toml_config": {
"package": {
"description": "Helps build scuba samples",
"description": "Provides Scuba sample type and sampling",
},
},
},
Expand All @@ -25,7 +25,6 @@ rust_library(
"fbsource//third-party/rust:serde_json",
"fbsource//third-party/rust:thiserror",
":scuba_sample_derive",
"//common/rust/shed/fbinit:fbinit",
],
)

Expand All @@ -49,6 +48,42 @@ rust_library(
],
)

rust_library(
name = "scuba_sample_builder",
srcs = glob(["builder/src/**/*.rs"]),
autocargo = {
"cargo_toml_config": {
"package": {
"description": "Helps build scuba samples",
},
},
"cargo_toml_dir": "builder/",
},
deps = [
"fbsource//third-party/rust:rand",
"fbsource//third-party/rust:serde_json",
":scuba_sample",
"//common/rust/shed/fbinit:fbinit",
],
)

rust_library(
name = "scuba_sample_client",
srcs = glob(["client/src/**/*.rs"]),
autocargo = {
"cargo_toml_config": {
"package": {
"description": "Provides scuba sample client stub",
},
},
"cargo_toml_dir": "client/",
},
deps = [
":scuba_sample",
"//common/rust/shed/fbinit:fbinit",
],
)

rust_unittest(
name = "scuba_sample_derive_test",
srcs = glob(["derive_tests/**/*.rs"]),
Expand Down
3 changes: 1 addition & 2 deletions shed/scuba_sample/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ name = "scuba_sample"
version = "0.1.0"
authors = ["Facebook <[email protected]>"]
edition = "2021"
description = "Helps build scuba samples"
description = "Provides Scuba sample type and sampling"
readme = "../../README.md"
repository = "https://github.com/facebookexperimental/rust-shed"
license = "MIT OR Apache-2.0"

[dependencies]
fbinit = { version = "0.2.0", path = "../fbinit" }
rand = { version = "0.8", features = ["small_rng"] }
scuba_sample_derive = { version = "0.1.0", path = "derive" }
serde = { version = "1.0.185", features = ["derive", "rc"] }
Expand Down
17 changes: 17 additions & 0 deletions shed/scuba_sample/builder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @generated by autocargo from //common/rust/shed/scuba_sample:scuba_sample_builder

[package]
name = "scuba_sample_builder"
version = "0.1.0"
authors = ["Facebook <[email protected]>"]
edition = "2021"
description = "Helps build scuba samples"
readme = "../../../README.md"
repository = "https://github.com/facebookexperimental/rust-shed"
license = "MIT OR Apache-2.0"

[dependencies]
fbinit = { version = "0.2.0", path = "../../fbinit" }
rand = { version = "0.8", features = ["small_rng"] }
scuba_sample = { version = "0.1.0", path = ".." }
serde_json = { version = "1.0.132", features = ["float_roundtrip", "unbounded_depth"] }
File renamed without changes.
19 changes: 19 additions & 0 deletions shed/scuba_sample/builder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/

#![deny(warnings, missing_docs, clippy::all, rustdoc::broken_intra_doc_links)]
#![allow(elided_lifetimes_in_paths)]

//! Defines [builder::ScubaSampleBuilder] helper structure to build a sample for Scuba.
pub mod builder;

use scuba_sample::*;

pub use crate::builder::ScubaSampleBuilder;
15 changes: 15 additions & 0 deletions shed/scuba_sample/client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# @generated by autocargo from //common/rust/shed/scuba_sample:scuba_sample_client

[package]
name = "scuba_sample_client"
version = "0.1.0"
authors = ["Facebook <[email protected]>"]
edition = "2021"
description = "Provides scuba sample client stub"
readme = "../../../README.md"
repository = "https://github.com/facebookexperimental/rust-shed"
license = "MIT OR Apache-2.0"

[dependencies]
fbinit = { version = "0.2.0", path = "../../fbinit" }
scuba_sample = { version = "0.1.0", path = ".." }
File renamed without changes.
19 changes: 19 additions & 0 deletions shed/scuba_sample/client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/

#![deny(warnings, missing_docs, clippy::all, rustdoc::broken_intra_doc_links)]
#![allow(elided_lifetimes_in_paths)]

//! Defines [client::ScubaClient] helper structure.
pub mod client;

use scuba_sample::*;

pub use crate::client::ScubaClient;
8 changes: 1 addition & 7 deletions shed/scuba_sample/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,19 @@
#![deny(warnings, missing_docs, clippy::all, rustdoc::broken_intra_doc_links)]
#![allow(elided_lifetimes_in_paths)]

//! Defines the [sample::ScubaSample] structure and the
//! [builder::ScubaSampleBuilder] helper structure to build a sample for
//! Scuba.
//! Defines the [sample::ScubaSample] structure.
//!
//! Scuba is a system that can aggregate log lines in a structured manner, this
//! crates also defines means to serialize the dataset into json format
//! understandable by Scuba.
pub mod builder;
pub mod client;
pub mod sample;
pub mod value;

mod sampling;

pub use scuba_sample_derive::*;

pub use crate::builder::ScubaSampleBuilder;
pub use crate::client::ScubaClient;
pub use crate::sample::Error;
pub use crate::sample::ScubaSample;
pub use crate::sample::StructuredSample;
Expand Down
4 changes: 4 additions & 0 deletions shed/scuba_stub/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ rust_library(
"extra_buck_dependencies": {
"dependencies": [
"//common/rust/shed/scuba_sample:scuba_sample",
"//common/rust/shed/scuba_sample:scuba_sample_builder",
"//common/rust/shed/scuba_sample:scuba_sample_client",
],
},
"lints": {
Expand All @@ -31,5 +33,7 @@ rust_library(
},
deps = [] + ([
"//common/rust/shed/scuba_sample:scuba_sample",
"//common/rust/shed/scuba_sample:scuba_sample_builder",
"//common/rust/shed/scuba_sample:scuba_sample_client",
] if rust_oss.is_oss_build() else []),
)
2 changes: 2 additions & 0 deletions shed/scuba_stub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ license = "MIT OR Apache-2.0"

[dependencies]
scuba_sample = { version = "0.1.0", path = "../scuba_sample" }
scuba_sample_builder = { version = "0.1.0", path = "../scuba_sample/builder" }
scuba_sample_client = { version = "0.1.0", path = "../scuba_sample/client" }

[lints]
rust = { unexpected_cfgs = { check-cfg = ["cfg(fbcode_build)"], level = "warn" } }
4 changes: 4 additions & 0 deletions shed/scuba_stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@
pub use fb_scuba::*;
#[cfg(not(fbcode_build))]
pub use scuba_sample::*;
#[cfg(not(fbcode_build))]
pub use scuba_sample_builder::*;
#[cfg(not(fbcode_build))]
pub use scuba_sample_client::*;

0 comments on commit 63c543b

Please sign in to comment.