Skip to content

Commit 12b24be

Browse files
authored
Rename variants to Rust standards (#1666)
`non_camel_case_types` has been changed to use `serde`'s renaming functionality, with the variants being renamed
1 parent c196ce4 commit 12b24be

29 files changed

+239
-239
lines changed

nativelink-config/src/cas_server.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ pub type SchedulerRefName = String;
3232
/// Used when the config references `instance_name` in the protocol.
3333
pub type InstanceName = String;
3434

35-
#[allow(non_camel_case_types)]
3635
#[derive(Deserialize, Debug, Default, Clone, Copy)]
36+
#[serde(rename_all = "snake_case")]
3737
pub enum HttpCompressionAlgorithm {
3838
/// No compression.
3939
#[default]
40-
none,
40+
None,
4141

4242
/// Zlib compression.
43-
gzip,
43+
Gzip,
4444
}
4545

4646
/// Note: Compressing data in the cloud rarely has a benefit, since most
@@ -61,7 +61,7 @@ pub struct HttpCompressionConfig {
6161
/// latency.
6262
/// see: <https://github.com/tracemachina/nativelink/issues/109>
6363
///
64-
/// Default: `HttpCompressionAlgorithm::none`
64+
/// Default: `HttpCompressionAlgorithm::None`
6565
pub send_compression_algorithm: Option<HttpCompressionAlgorithm>,
6666

6767
/// The compression algorithm that the server will accept from clients.
@@ -394,11 +394,11 @@ pub struct HttpServerConfig {
394394
pub experimental_http2_max_header_list_size: Option<u32>,
395395
}
396396

397-
#[allow(non_camel_case_types)]
398397
#[derive(Deserialize, Debug)]
398+
#[serde(rename_all = "snake_case")]
399399
pub enum ListenerConfig {
400400
/// Listener for HTTP/HTTPS/HTTP2 sockets.
401-
http(HttpListener),
401+
Http(HttpListener),
402402
}
403403

404404
#[derive(Deserialize, Debug)]
@@ -447,18 +447,18 @@ pub struct ServerConfig {
447447
pub experimental_identity_header: IdentityHeaderSpec,
448448
}
449449

450-
#[allow(non_camel_case_types)]
451450
#[derive(Deserialize, Debug)]
451+
#[serde(rename_all = "snake_case")]
452452
pub enum WorkerProperty {
453453
/// List of static values.
454454
/// Note: Generally there should only ever be 1 value, but if the platform
455455
/// property key is `PropertyType::Priority` it may have more than one value.
456456
#[serde(deserialize_with = "convert_vec_string_with_shellexpand")]
457-
values(Vec<String>),
457+
Values(Vec<String>),
458458

459459
/// A dynamic configuration. The string will be executed as a command
460460
/// (not sell) and will be split by "\n" (new line character).
461-
query_cmd(String),
461+
QueryCmd(String),
462462
}
463463

464464
/// Generic config for an endpoint and associated configs.
@@ -477,35 +477,35 @@ pub struct EndpointConfig {
477477
pub tls_config: Option<ClientTlsConfig>,
478478
}
479479

480-
#[allow(non_camel_case_types)]
481480
#[derive(Copy, Clone, Deserialize, Debug, Default)]
481+
#[serde(rename_all = "snake_case")]
482482
pub enum UploadCacheResultsStrategy {
483483
/// Only upload action results with an exit code of 0.
484484
#[default]
485-
success_only,
485+
SuccessOnly,
486486

487487
/// Don't upload any action results.
488-
never,
488+
Never,
489489

490490
/// Upload all action results that complete.
491-
everything,
491+
Everything,
492492

493493
/// Only upload action results that fail.
494-
failures_only,
494+
FailuresOnly,
495495
}
496496

497-
#[allow(non_camel_case_types)]
498497
#[derive(Clone, Deserialize, Debug)]
498+
#[serde(rename_all = "snake_case")]
499499
pub enum EnvironmentSource {
500500
/// The name of the platform property in the action to get the value from.
501-
property(String),
501+
Property(String),
502502

503503
/// The raw value to set.
504-
value(#[serde(deserialize_with = "convert_string_with_shellexpand")] String),
504+
Value(#[serde(deserialize_with = "convert_string_with_shellexpand")] String),
505505

506506
/// The max amount of time in milliseconds the command is allowed to run
507507
/// (requested by the client).
508-
timeout_millis,
508+
TimeoutMillis,
509509

510510
/// A special file path will be provided that can be used to communicate
511511
/// with the parent process about out-of-band information. This file
@@ -523,7 +523,7 @@ pub enum EnvironmentSource {
523523
///
524524
/// All fields are optional, file does not need to be created and may be
525525
/// empty.
526-
side_channel_file,
526+
SideChannelFile,
527527

528528
/// A "root" directory for the action. This directory can be used to
529529
/// store temporary files that are not needed after the action has
@@ -538,7 +538,7 @@ pub enum EnvironmentSource {
538538
/// variable, `mkdir $ENV_VAR_NAME/tmp` and `export TMPDIR=$ENV_VAR_NAME/tmp`.
539539
/// Another example might be to bind-mount the `/tmp` path in a container to
540540
/// this path in `entrypoint`.
541-
action_directory,
541+
ActionDirectory,
542542
}
543543

544544
#[derive(Deserialize, Debug, Default)]
@@ -693,11 +693,11 @@ pub struct LocalWorkerConfig {
693693
pub additional_environment: Option<HashMap<String, EnvironmentSource>>,
694694
}
695695

696-
#[allow(non_camel_case_types)]
697696
#[derive(Deserialize, Debug)]
697+
#[serde(rename_all = "snake_case")]
698698
pub enum WorkerConfig {
699699
/// A worker type that executes jobs locally on this machine.
700-
local(LocalWorkerConfig),
700+
Local(LocalWorkerConfig),
701701
}
702702

703703
#[derive(Deserialize, Debug, Clone, Copy)]

nativelink-config/src/schedulers.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,50 +19,50 @@ use serde::Deserialize;
1919
use crate::serde_utils::{convert_duration_with_shellexpand, convert_numeric_with_shellexpand};
2020
use crate::stores::{GrpcEndpoint, Retry, StoreRefName};
2121

22-
#[allow(non_camel_case_types)]
2322
#[derive(Deserialize, Debug)]
23+
#[serde(rename_all = "snake_case")]
2424
pub enum SchedulerSpec {
25-
simple(SimpleSpec),
26-
grpc(GrpcSpec),
27-
cache_lookup(CacheLookupSpec),
28-
property_modifier(PropertyModifierSpec),
25+
Simple(SimpleSpec),
26+
Grpc(GrpcSpec),
27+
CacheLookup(CacheLookupSpec),
28+
PropertyModifier(PropertyModifierSpec),
2929
}
3030

3131
/// When the scheduler matches tasks to workers that are capable of running
3232
/// the task, this value will be used to determine how the property is treated.
33-
#[allow(non_camel_case_types)]
3433
#[derive(Deserialize, Debug, Clone, Copy, Hash, Eq, PartialEq)]
34+
#[serde(rename_all = "snake_case")]
3535
pub enum PropertyType {
3636
/// Requires the platform property to be a u64 and when the scheduler looks
3737
/// for appropriate worker nodes that are capable of executing the task,
3838
/// the task will not run on a node that has less than this value.
39-
minimum,
39+
Minimum,
4040

4141
/// Requires the platform property to be a string and when the scheduler
4242
/// looks for appropriate worker nodes that are capable of executing the
4343
/// task, the task will not run on a node that does not have this property
4444
/// set to the value with exact string match.
45-
exact,
45+
Exact,
4646

4747
/// Does not restrict on this value and instead will be passed to the worker
4848
/// as an informational piece.
4949
/// TODO(allada) In the future this will be used by the scheduler and worker
5050
/// to cause the scheduler to prefer certain workers over others, but not
5151
/// restrict them based on these values.
52-
priority,
52+
Priority,
5353
}
5454

5555
/// When a worker is being searched for to run a job, this will be used
5656
/// on how to choose which worker should run the job when multiple
5757
/// workers are able to run the task.
58-
#[allow(non_camel_case_types)]
5958
#[derive(Copy, Clone, Deserialize, Debug, Default)]
59+
#[serde(rename_all = "snake_case")]
6060
pub enum WorkerAllocationStrategy {
6161
/// Prefer workers that have been least recently used to run a job.
6262
#[default]
63-
least_recently_used,
63+
LeastRecentlyUsed,
6464
/// Prefer workers that have been most recently used to run a job.
65-
most_recently_used,
65+
MostRecentlyUsed,
6666
}
6767

6868
#[derive(Deserialize, Debug, Default)]
@@ -131,13 +131,13 @@ pub struct SimpleSpec {
131131
pub experimental_backend: Option<ExperimentalSimpleSchedulerBackend>,
132132
}
133133

134-
#[allow(non_camel_case_types)]
135134
#[derive(Deserialize, Debug)]
135+
#[serde(rename_all = "snake_case")]
136136
pub enum ExperimentalSimpleSchedulerBackend {
137137
/// Use an in-memory store for the scheduler.
138-
memory,
138+
Memory,
139139
/// Use a redis store for the scheduler.
140-
redis(ExperimentalRedisSchedulerBackend),
140+
Redis(ExperimentalRedisSchedulerBackend),
141141
}
142142

143143
#[derive(Deserialize, Debug, Default)]
@@ -195,13 +195,13 @@ pub struct PlatformPropertyAddition {
195195
pub value: String,
196196
}
197197

198-
#[allow(non_camel_case_types)]
199198
#[derive(Deserialize, Debug, Clone)]
199+
#[serde(rename_all = "snake_case")]
200200
pub enum PropertyModification {
201201
/// Add a property to the action properties.
202-
add(PlatformPropertyAddition),
202+
Add(PlatformPropertyAddition),
203203
/// Remove a named property from the action.
204-
remove(String),
204+
Remove(String),
205205
}
206206

207207
#[derive(Deserialize, Debug)]

0 commit comments

Comments
 (0)