diff --git a/.gitignore b/.gitignore index a506158a4..0fae077e8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ nixos.bazelrc rust-project.json darwin.bazelrc nativelink.bazelrc +nativelink_config.schema.json diff --git a/Cargo.lock b/Cargo.lock index 740e2cd26..5234200cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1075,6 +1075,12 @@ dependencies = [ "syn 2.0.100", ] +[[package]] +name = "dyn-clone" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" + [[package]] name = "either" version = "1.15.0" @@ -2075,6 +2081,7 @@ dependencies = [ "byte-unit", "humantime", "pretty_assertions", + "schemars", "serde", "serde_json", "serde_json5", @@ -3110,6 +3117,30 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "schemars" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.100", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -3200,6 +3231,17 @@ dependencies = [ "syn 2.0.100", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "serde_json" version = "1.0.140" diff --git a/nativelink-config/Cargo.toml b/nativelink-config/Cargo.toml index 41a4855b5..0fbe2c1a3 100644 --- a/nativelink-config/Cargo.toml +++ b/nativelink-config/Cargo.toml @@ -9,7 +9,17 @@ humantime = "2.1.0" serde = { version = "1.0.218", default-features = false, features = ["derive"] } serde_json5 = "0.2.1" shellexpand = { version = "3.1.0", default-features = false, features = ["base-0"] } +schemars = { version = "0.8.22", features = ["derive"], optional = true } +serde_json = { version = "1.0.139", default-features = false, optional = true } [dev-dependencies] pretty_assertions = { version = "1.4.1", features = ["std"] } serde_json = { version = "1.0.139", default-features = false } + +[features] +dev-schema = ["schemars", "serde_json"] + +[[bin]] +name = "build-schema" +path = "src/bin/build_schema.rs" +required-features=["dev-schema"] diff --git a/nativelink-config/src/bin/build_schema.rs b/nativelink-config/src/bin/build_schema.rs new file mode 100644 index 000000000..3d4936264 --- /dev/null +++ b/nativelink-config/src/bin/build_schema.rs @@ -0,0 +1,24 @@ +//! ```sh +//! cargo run --bin build-schema --features dev-schema --package nativelink-config +//! ``` + +#[cfg(feature = "dev-schema")] +fn main() { + use std::fs::File; + + use nativelink_config::cas_server::CasConfig; + use schemars::schema_for; + use serde_json::to_writer_pretty; + const FILE: &str = "nativelink_config.schema.json"; + + let schema = schema_for!(CasConfig); + to_writer_pretty(File::create(FILE).expect("to create file"), &schema) + .expect("to export schema"); + + println!("Wrote schema to {FILE}"); +} + +#[cfg(not(feature = "dev-schema"))] +fn main() { + eprintln!("Enable with --features dev-schema"); +} diff --git a/nativelink-config/src/cas_server.rs b/nativelink-config/src/cas_server.rs index a2dfd6bc5..78ced6fc6 100644 --- a/nativelink-config/src/cas_server.rs +++ b/nativelink-config/src/cas_server.rs @@ -14,6 +14,8 @@ use std::collections::HashMap; +#[cfg(feature = "dev-schema")] +use schemars::JsonSchema; use serde::Deserialize; use crate::serde_utils::{ @@ -34,6 +36,7 @@ pub type InstanceName = String; #[allow(non_camel_case_types)] #[derive(Deserialize, Debug, Default, Clone, Copy)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum HttpCompressionAlgorithm { /// No compression. #[default] @@ -54,6 +57,7 @@ pub enum HttpCompressionAlgorithm { /// and cloud-clients to use another. #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct HttpCompressionConfig { /// The compression algorithm that the server will use when sending /// responses to clients. Enabling this will likely save a lot of @@ -77,6 +81,7 @@ pub struct HttpCompressionConfig { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct AcStoreConfig { /// The store name referenced in the `stores` map in the main config. /// This store name referenced here may be reused multiple times. @@ -91,6 +96,7 @@ pub struct AcStoreConfig { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct CasStoreConfig { /// The store name referenced in the `stores` map in the main config. /// This store name referenced here may be reused multiple times. @@ -100,6 +106,7 @@ pub struct CasStoreConfig { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct CapabilitiesRemoteExecutionConfig { /// Scheduler used to configure the capabilities of remote execution. #[serde(deserialize_with = "convert_string_with_shellexpand")] @@ -108,6 +115,7 @@ pub struct CapabilitiesRemoteExecutionConfig { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct CapabilitiesConfig { /// Configuration for remote execution capabilities. /// If not set the capabilities service will inform the client that remote @@ -117,6 +125,7 @@ pub struct CapabilitiesConfig { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ExecutionConfig { /// The store name referenced in the `stores` map in the main config. /// This store name referenced here may be reused multiple times. @@ -131,6 +140,7 @@ pub struct ExecutionConfig { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ByteStreamConfig { /// Name of the store in the "stores" configuration. pub cas_stores: HashMap, @@ -161,6 +171,7 @@ pub struct ByteStreamConfig { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct WorkerApiConfig { /// The scheduler name referenced in the `schedulers` map in the main config. #[serde(deserialize_with = "convert_string_with_shellexpand")] @@ -169,6 +180,7 @@ pub struct WorkerApiConfig { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct PrometheusConfig { /// Path to register prometheus metrics. If path is "/metrics", and your /// domain is "example.com", you can reach the endpoint with: @@ -181,6 +193,7 @@ pub struct PrometheusConfig { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct AdminConfig { /// Path to register the admin API. If path is "/admin", and your /// domain is "example.com", you can reach the endpoint with: @@ -193,6 +206,7 @@ pub struct AdminConfig { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct HealthConfig { /// Path to register the health status check. If path is "/status", and your /// domain is "example.com", you can reach the endpoint with: @@ -204,6 +218,7 @@ pub struct HealthConfig { } #[derive(Deserialize, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct BepConfig { /// The store to publish build events to. /// The store name referenced in the `stores` map in the main config. @@ -212,6 +227,7 @@ pub struct BepConfig { } #[derive(Deserialize, Clone, Debug, Default)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct IdentityHeaderSpec { /// The name of the header to look for the identity in. /// Default: "x-identity" @@ -224,6 +240,7 @@ pub struct IdentityHeaderSpec { } #[derive(Deserialize, Clone, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct OriginEventsPublisherSpec { /// The store to publish nativelink events to. /// The store name referenced in the `stores` map in the main config. @@ -232,6 +249,7 @@ pub struct OriginEventsPublisherSpec { } #[derive(Deserialize, Clone, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct OriginEventsSpec { /// The publisher configuration for origin events. pub publisher: OriginEventsPublisherSpec, @@ -247,6 +265,7 @@ pub struct OriginEventsSpec { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ServicesConfig { /// The Content Addressable Storage (CAS) backend config. /// The key is the `instance_name` used in the protocol and the @@ -301,6 +320,7 @@ pub struct ServicesConfig { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct TlsConfig { /// Path to the certificate file. #[serde(deserialize_with = "convert_string_with_shellexpand")] @@ -329,6 +349,7 @@ pub struct TlsConfig { /// specified. #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct HttpServerConfig { /// Interval to send keep-alive pings via HTTP2. /// Note: This is in seconds. @@ -396,6 +417,7 @@ pub struct HttpServerConfig { #[allow(non_camel_case_types)] #[derive(Deserialize, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum ListenerConfig { /// Listener for HTTP/HTTPS/HTTP2 sockets. http(HttpListener), @@ -403,6 +425,7 @@ pub enum ListenerConfig { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct HttpListener { /// Address to listen on. Example: `127.0.0.1:8080` or `:8080` to listen /// to all IPs. @@ -427,6 +450,7 @@ pub struct HttpListener { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ServerConfig { /// Name of the server. This is used to help identify the service /// for telemetry and logs. @@ -449,6 +473,7 @@ pub struct ServerConfig { #[allow(non_camel_case_types)] #[derive(Deserialize, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum WorkerProperty { /// List of static values. /// Note: Generally there should only ever be 1 value, but if the platform @@ -464,6 +489,7 @@ pub enum WorkerProperty { /// Generic config for an endpoint and associated configs. #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct EndpointConfig { /// URI of the endpoint. #[serde(deserialize_with = "convert_string_with_shellexpand")] @@ -479,6 +505,7 @@ pub struct EndpointConfig { #[allow(non_camel_case_types)] #[derive(Copy, Clone, Deserialize, Debug, Default)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum UploadCacheResultsStrategy { /// Only upload action results with an exit code of 0. #[default] @@ -496,6 +523,7 @@ pub enum UploadCacheResultsStrategy { #[allow(non_camel_case_types)] #[derive(Clone, Deserialize, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum EnvironmentSource { /// The name of the platform property in the action to get the value from. property(String), @@ -543,6 +571,7 @@ pub enum EnvironmentSource { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct UploadActionResultConfig { /// Underlying AC store that the worker will use to publish execution results /// into. Objects placed in this store should be reachable from the @@ -603,6 +632,7 @@ pub struct UploadActionResultConfig { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct LocalWorkerConfig { /// Name of the worker. This is give a more friendly name to a worker for logging /// and metric publishing. This is also the prefix of the worker id @@ -695,6 +725,7 @@ pub struct LocalWorkerConfig { #[allow(non_camel_case_types)] #[derive(Deserialize, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum WorkerConfig { /// A worker type that executes jobs locally on this machine. local(LocalWorkerConfig), @@ -702,6 +733,7 @@ pub enum WorkerConfig { #[derive(Deserialize, Debug, Clone, Copy)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct GlobalConfig { /// Maximum number of open files that can be opened at one time. /// This value is not strictly enforced, it is a best effort. Some internal libraries @@ -747,6 +779,7 @@ pub struct GlobalConfig { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct CasConfig { /// List of stores available to use in this config. /// The keys can be used in other configs when needing to reference a store. diff --git a/nativelink-config/src/lib.rs b/nativelink-config/src/lib.rs index 0a76ac9c7..b46ab18cd 100644 --- a/nativelink-config/src/lib.rs +++ b/nativelink-config/src/lib.rs @@ -22,10 +22,12 @@ use std::collections::HashMap; use std::fmt; use std::marker::PhantomData; +#[cfg(feature = "dev-schema")] +use schemars::JsonSchema; use serde::de::{MapAccess, SeqAccess, Visitor}; use serde::{Deserialize, Deserializer}; - #[derive(Debug, Clone, Deserialize)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct NamedConfig { pub name: String, #[serde(flatten)] @@ -41,6 +43,7 @@ pub type StoreConfigs = NamedConfigs; pub type SchedulerConfigs = NamedConfigs; #[derive(Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct NamedConfigs(pub Vec>); impl NamedConfigs { diff --git a/nativelink-config/src/schedulers.rs b/nativelink-config/src/schedulers.rs index 35d84a76e..4cc8a16f5 100644 --- a/nativelink-config/src/schedulers.rs +++ b/nativelink-config/src/schedulers.rs @@ -14,6 +14,8 @@ use std::collections::HashMap; +#[cfg(feature = "dev-schema")] +use schemars::JsonSchema; use serde::Deserialize; use crate::serde_utils::{convert_duration_with_shellexpand, convert_numeric_with_shellexpand}; @@ -21,6 +23,7 @@ use crate::stores::{GrpcEndpoint, Retry, StoreRefName}; #[allow(non_camel_case_types)] #[derive(Deserialize, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum SchedulerSpec { simple(SimpleSpec), grpc(GrpcSpec), @@ -32,6 +35,7 @@ pub enum SchedulerSpec { /// the task, this value will be used to determine how the property is treated. #[allow(non_camel_case_types)] #[derive(Deserialize, Debug, Clone, Copy, Hash, Eq, PartialEq)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum PropertyType { /// Requires the platform property to be a u64 and when the scheduler looks /// for appropriate worker nodes that are capable of executing the task, @@ -57,6 +61,7 @@ pub enum PropertyType { /// workers are able to run the task. #[allow(non_camel_case_types)] #[derive(Copy, Clone, Deserialize, Debug, Default)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum WorkerAllocationStrategy { /// Prefer workers that have been least recently used to run a job. #[default] @@ -67,6 +72,7 @@ pub enum WorkerAllocationStrategy { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct SimpleSpec { /// A list of supported platform properties mapped to how these properties /// are used when the scheduler looks for worker nodes capable of running @@ -133,6 +139,7 @@ pub struct SimpleSpec { #[allow(non_camel_case_types)] #[derive(Deserialize, Debug)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum ExperimentalSimpleSchedulerBackend { /// Use an in-memory store for the scheduler. memory, @@ -142,6 +149,7 @@ pub enum ExperimentalSimpleSchedulerBackend { #[derive(Deserialize, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ExperimentalRedisSchedulerBackend { /// A reference to the redis store to use for the scheduler. /// Note: This MUST resolve to a `RedisSpec`. @@ -154,6 +162,7 @@ pub struct ExperimentalRedisSchedulerBackend { /// build at the main scheduler directly though. #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct GrpcSpec { /// The upstream scheduler to forward requests to. pub endpoint: GrpcEndpoint, @@ -176,6 +185,7 @@ pub struct GrpcSpec { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct CacheLookupSpec { /// The reference to the action cache store used to return cached /// actions from rather than running them again. @@ -188,6 +198,7 @@ pub struct CacheLookupSpec { #[derive(Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct PlatformPropertyAddition { /// The name of the property to add. pub name: String, @@ -197,6 +208,7 @@ pub struct PlatformPropertyAddition { #[allow(non_camel_case_types)] #[derive(Deserialize, Debug, Clone)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum PropertyModification { /// Add a property to the action properties. add(PlatformPropertyAddition), @@ -206,6 +218,7 @@ pub enum PropertyModification { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct PropertyModifierSpec { /// A list of modifications to perform to incoming actions for the nested /// scheduler. These are performed in order and blindly, so removing a diff --git a/nativelink-config/src/stores.rs b/nativelink-config/src/stores.rs index fc5d492be..d95af8707 100644 --- a/nativelink-config/src/stores.rs +++ b/nativelink-config/src/stores.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#[cfg(feature = "dev-schema")] +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::serde_utils::{ @@ -26,6 +28,7 @@ pub type StoreRefName = String; #[allow(non_camel_case_types)] #[derive(Serialize, Deserialize, Debug, Clone, Copy)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum ConfigDigestHashFunction { /// Use the sha256 hash function. /// @@ -38,6 +41,7 @@ pub enum ConfigDigestHashFunction { #[allow(non_camel_case_types)] #[derive(Serialize, Deserialize, Debug, Clone)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum StoreSpec { /// Memory store will store all data in a hashmap in memory. /// @@ -433,6 +437,7 @@ pub enum StoreSpec { /// Configuration for an individual shard of the store. #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ShardConfig { /// Store to shard the data to. pub store: StoreSpec, @@ -447,6 +452,7 @@ pub struct ShardConfig { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ShardSpec { /// Stores to shard the data to. pub stores: Vec, @@ -454,6 +460,7 @@ pub struct ShardSpec { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct SizePartitioningSpec { /// Size to partition the data on. #[serde(deserialize_with = "convert_data_size_with_shellexpand")] @@ -468,6 +475,7 @@ pub struct SizePartitioningSpec { #[derive(Serialize, Deserialize, Debug, Default, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct RefSpec { /// Name of the store under the root "stores" config object. #[serde(deserialize_with = "convert_string_with_shellexpand")] @@ -476,6 +484,7 @@ pub struct RefSpec { #[derive(Serialize, Deserialize, Debug, Default, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct FilesystemSpec { /// Path on the system where to store the actual content. This is where /// the bulk of the data will be placed. @@ -514,6 +523,7 @@ pub struct FilesystemSpec { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct FastSlowSpec { /// Fast store that will be attempted to be contacted before reaching /// out to the `slow` store. @@ -526,6 +536,7 @@ pub struct FastSlowSpec { #[derive(Serialize, Deserialize, Debug, Default, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct MemorySpec { /// Policy used to evict items out of the store. Failure to set this /// value will cause items to never be removed from the store causing @@ -535,6 +546,7 @@ pub struct MemorySpec { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct DedupSpec { /// Store used to store the index of each dedup slice. This store /// should generally be fast and small. @@ -590,6 +602,7 @@ pub struct DedupSpec { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ExistenceCacheSpec { /// The underlying store wrap around. All content will first flow /// through self before forwarding to backend. In the event there @@ -606,6 +619,7 @@ pub struct ExistenceCacheSpec { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct VerifySpec { /// The underlying store wrap around. All content will first flow /// through self before forwarding to backend. In the event there @@ -632,6 +646,7 @@ pub struct VerifySpec { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct CompletenessCheckingSpec { /// The underlying store that will have it's results validated before sending to client. pub backend: StoreSpec, @@ -643,6 +658,7 @@ pub struct CompletenessCheckingSpec { #[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone, Copy)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct Lz4Config { /// Size of the blocks to compress. /// Higher values require more ram, but might yield slightly better @@ -666,6 +682,7 @@ pub struct Lz4Config { #[allow(non_camel_case_types)] #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum CompressionAlgorithm { /// LZ4 compression algorithm is extremely fast for compression and /// decompression, however does not perform very well in compression @@ -679,6 +696,7 @@ pub enum CompressionAlgorithm { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct CompressionSpec { /// The underlying store wrap around. All content will first flow /// through self before forwarding to backend. In the event there @@ -697,6 +715,7 @@ pub struct CompressionSpec { /// until the store size becomes smaller than `max_bytes`. #[derive(Serialize, Deserialize, Debug, Default, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct EvictionPolicy { /// Maximum number of bytes before eviction takes place. /// Default: 0. Zero means never evict based on size. @@ -724,6 +743,7 @@ pub struct EvictionPolicy { #[derive(Serialize, Deserialize, Debug, Default, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct S3Spec { /// S3 region. Usually us-east-1, us-west-2, af-south-1, exc... #[serde(default, deserialize_with = "convert_string_with_shellexpand")] @@ -787,6 +807,7 @@ pub struct S3Spec { #[allow(non_camel_case_types)] #[derive(Serialize, Deserialize, Debug, Clone, Copy)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum StoreType { /// The store is content addressable storage. cas, @@ -795,6 +816,7 @@ pub enum StoreType { } #[derive(Serialize, Deserialize, Debug, Clone)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct ClientTlsConfig { /// Path to the certificate authority to use to validate the remote. #[serde(deserialize_with = "convert_string_with_shellexpand")] @@ -811,6 +833,7 @@ pub struct ClientTlsConfig { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct GrpcEndpoint { /// The endpoint address (i.e. grpc(s)://example.com:443). #[serde(deserialize_with = "convert_string_with_shellexpand")] @@ -823,6 +846,7 @@ pub struct GrpcEndpoint { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct GrpcSpec { /// Instance name for GRPC calls. Proxy calls will have the `instance_name` changed to this. #[serde(default, deserialize_with = "convert_string_with_shellexpand")] @@ -852,6 +876,7 @@ pub struct GrpcSpec { /// The possible error codes that might occur on an upstream request. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum ErrorCode { Cancelled = 1, Unknown = 2, @@ -873,6 +898,7 @@ pub enum ErrorCode { } #[derive(Serialize, Deserialize, Debug, Clone)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct RedisSpec { /// The hostname or IP address of the Redis server. /// Ex: `["redis://username:password@redis-server-url:6380/99"]` @@ -993,6 +1019,7 @@ pub struct RedisSpec { #[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub enum RedisMode { Cluster, Sentinel, @@ -1001,6 +1028,7 @@ pub enum RedisMode { } #[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct NoopSpec {} /// Retry configuration. This configuration is exponential and each iteration @@ -1026,6 +1054,7 @@ pub struct NoopSpec {} /// would mean a single request would have a total delay of 9.525s - 15.875s. #[derive(Serialize, Deserialize, Clone, Debug, Default)] #[serde(deny_unknown_fields)] +#[cfg_attr(feature = "dev-schema", derive(JsonSchema))] pub struct Retry { /// Maximum number of retries until retrying stops. /// Setting this to zero will always attempt 1 time, but not retry.