Skip to content

Commit

Permalink
chore: Update to Rust 1.85 and 2024 edition (#1129)
Browse files Browse the repository at this point in the history
* chore: Update to Rust 1.85 and 2024 edition

* Regen protos

* Remove workspace dep check for now

* Use 2024 formatting

* Format

---------

Co-authored-by: Jake Shadle <[email protected]>
  • Loading branch information
XAMPPRocky and Jake-Shadle authored Feb 21, 2025
1 parent d62cbbf commit d4733c5
Show file tree
Hide file tree
Showing 79 changed files with 588 additions and 550 deletions.
145 changes: 69 additions & 76 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ members = [

[workspace.package]
license = "Apache-2.0"
edition = "2021"
edition = "2024"

[workspace.dependencies]
arc-swap = { version = "1.7.1", features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion benches/cluster_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const SEEDS: &[u64] = &[100, 200, 300, 400, 500];
#[divan::bench_group(sample_count = 10)]
mod ops {
use super::*;
use shared::{gen_cluster_map, GenCluster};
use shared::{GenCluster, gen_cluster_map};

fn compute_hash<const S: u64>(gc: &GenCluster) -> usize {
let mut total_endpoints = 0;
Expand Down
22 changes: 11 additions & 11 deletions benches/misc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(target_pointer_width = "64")]

use divan::Bencher;
use prost_types::{value::Kind, Value};
use prost_types::{Value, value::Kind};
use rand::SeedableRng;

use quilkin::{net::cluster::proto::Endpoint as ProtoEndpoint, xds::Resource};
Expand Down Expand Up @@ -79,21 +79,21 @@ impl GenAddress for Ip {
fn generate(&mut self, slim: bool) -> (usize, ProtoEndpoint) {
let ip = if self.counter % 2 == 0 {
std::net::Ipv6Addr::new(
(self.counter >> 112 & 0xffff) as _,
(self.counter >> 96 & 0xffff) as _,
(self.counter >> 80 & 0xffff) as _,
(self.counter >> 64 & 0xffff) as _,
(self.counter >> 48 & 0xffff) as _,
(self.counter >> 32 & 0xffff) as _,
(self.counter >> 16 & 0xffff) as _,
((self.counter >> 112) & 0xffff) as _,
((self.counter >> 96) & 0xffff) as _,
((self.counter >> 80) & 0xffff) as _,
((self.counter >> 64) & 0xffff) as _,
((self.counter >> 48) & 0xffff) as _,
((self.counter >> 32) & 0xffff) as _,
((self.counter >> 16) & 0xffff) as _,
(self.counter & 0xffff) as _,
)
.into()
} else {
std::net::Ipv4Addr::new(
(self.counter >> 24 & 0xff) as _,
(self.counter >> 16 & 0xff) as _,
(self.counter >> 8 & 0xff) as _,
((self.counter >> 24) & 0xff) as _,
((self.counter >> 16) & 0xff) as _,
((self.counter >> 8) & 0xff) as _,
(self.counter & 0xff) as _,
)
.into()
Expand Down
16 changes: 10 additions & 6 deletions benches/read_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ mod read {
let (tx, rx) = channel();
let writer = Writer::<N>::new(writer, reader.local_addr().unwrap(), rx);

spawn(format!("direct_writer_{N}"), move || loop {
if !writer.write_all(NUMBER_OF_PACKETS) {
break;
spawn(format!("direct_writer_{N}"), move || {
loop {
if !writer.write_all(NUMBER_OF_PACKETS) {
break;
}
}
});

Expand All @@ -42,9 +44,11 @@ mod read {
let writer = Writer::<N>::new(writer, (Ipv4Addr::LOCALHOST, READ_QUILKIN_PORT).into(), rx);
let _quilkin_loop = writer.wait_ready(quilkin_loop, &reader);

spawn(format!("quilkin_writer_{N}"), move || loop {
if !writer.write_all(NUMBER_OF_PACKETS) {
break;
spawn(format!("quilkin_writer_{N}"), move || {
loop {
if !writer.write_all(NUMBER_OF_PACKETS) {
break;
}
}
});

Expand Down
6 changes: 3 additions & 3 deletions benches/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pub use std::{
net::{Ipv4Addr, SocketAddr, UdpSocket},
sync::{mpsc, Arc},
sync::{Arc, mpsc},
};

pub const READ_QUILKIN_PORT: u16 = 9001;
Expand Down Expand Up @@ -138,7 +138,7 @@ pub fn read_to_end<const N: usize>(
assert_eq!(length, N);

{
let seq = (packet[1] as u16) << 8 | packet[0] as u16;
let seq = ((packet[1] as u16) << 8) | packet[0] as u16;

let batch = batches.iter_mut().find(|b| b.range.contains(&seq)).unwrap();

Expand Down Expand Up @@ -367,7 +367,7 @@ impl Drop for QuilkinLoop {
}
}

use quilkin::net::{cluster::ClusterMap, endpoint::Locality, Endpoint, EndpointAddress};
use quilkin::net::{Endpoint, EndpointAddress, cluster::ClusterMap, endpoint::Locality};
use rand::Rng;
use std::{
collections::BTreeSet,
Expand Down
4 changes: 2 additions & 2 deletions crates/agones/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
name = "agones"
authors = ["Mark Mandel <[email protected]>"]
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
edition.workspace = true
license.workspace = true
description = "End to end integration tests to be run against a Kubernetes cluster with Agones installed"
readme = "README.md"

Expand Down
4 changes: 2 additions & 2 deletions crates/agones/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ use k8s_openapi::{
chrono,
};
use kube::{
api::{DeleteParams, ListParams, LogParams, PostParams},
runtime::wait::{await_condition, Condition},
Api, Resource, ResourceExt,
api::{DeleteParams, ListParams, LogParams, PostParams},
runtime::wait::{Condition, await_condition},
};
use tokio::{sync::OnceCell, time::timeout};
use tracing::debug;
Expand Down
4 changes: 2 additions & 2 deletions crates/agones/src/pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ mod tests {
api::core::v1::{Pod, PodSpec},
apimachinery::pkg::apis::meta::v1::ObjectMeta,
};
use kube::{api::PostParams, runtime::wait::await_condition, Api, ResourceExt};
use kube::{Api, ResourceExt, api::PostParams, runtime::wait::await_condition};
use std::time::Duration;
use tokio::time::timeout;

use crate::{is_pod_ready, quilkin_container, Client};
use crate::{Client, is_pod_ready, quilkin_container};

#[tokio::test]
async fn create_quilkin_pod() {
Expand Down
8 changes: 4 additions & 4 deletions crates/agones/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ mod tests {
},
};
use kube::{
Api, ResourceExt,
api::{DeleteParams, PostParams},
runtime::wait::await_condition,
Api, ResourceExt,
};
use serial_test::serial;
use tokio::time::timeout;
Expand All @@ -46,9 +46,9 @@ mod tests {
};

use crate::{
create_agones_rbac_read_account, create_token_router_config, create_tokenised_gameserver,
debug_pods, is_deployment_ready, quilkin_container, quilkin_proxy_deployment, Client,
TOKEN_KEY,
Client, TOKEN_KEY, create_agones_rbac_read_account, create_token_router_config,
create_tokenised_gameserver, debug_pods, is_deployment_ready, quilkin_container,
quilkin_proxy_deployment,
};

const PROXY_DEPLOYMENT: &str = "quilkin-xds-proxies";
Expand Down
8 changes: 4 additions & 4 deletions crates/agones/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ mod tests {
},
};
use kube::{
Api, ResourceExt,
api::{DeleteParams, PostParams},
runtime::wait::await_condition,
Api, ResourceExt,
};
use serial_test::serial;
use tokio::time::timeout;
Expand All @@ -46,9 +46,9 @@ mod tests {
};

use crate::{
create_agones_rbac_read_account, create_token_router_config, create_tokenised_gameserver,
debug_pods, is_deployment_ready, quilkin_container, quilkin_proxy_deployment, Client,
TOKEN_KEY,
Client, TOKEN_KEY, create_agones_rbac_read_account, create_token_router_config,
create_tokenised_gameserver, debug_pods, is_deployment_ready, quilkin_container,
quilkin_proxy_deployment,
};

const SLOW: Duration = Duration::from_secs(30);
Expand Down
4 changes: 2 additions & 2 deletions crates/agones/src/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#[cfg(test)]
mod tests {
use crate::{game_server, is_gameserver_ready, quilkin_config_map, quilkin_container, Client};
use crate::{Client, game_server, is_gameserver_ready, quilkin_config_map, quilkin_container};
use k8s_openapi::api::core::v1::{ConfigMap, ConfigMapVolumeSource, Volume};
use kube::{api::PostParams, runtime::wait::await_condition, Api, ResourceExt};
use kube::{Api, ResourceExt, api::PostParams, runtime::wait::await_condition};
use quilkin::{config::providers::k8s::agones::GameServer, test::TestHelper};
use std::time::Duration;
use tokio::time::timeout;
Expand Down
4 changes: 2 additions & 2 deletions crates/ebpf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "quilkin-ebpf"
version = "0.1.0"
license = "Apache-2.0"
edition = "2021"
license.workspace = true
edition.workspace = true

[dependencies]
aya-ebpf = "0.1.1"
Expand Down
4 changes: 2 additions & 2 deletions crates/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
name = "quilkin-macros"
version = "0.10.0-dev"
authors = ["Erin Power <[email protected]>"]
license = "Apache-2.0"
license.workspace = true
description = "Quilkin is a non-transparent UDP proxy specifically designed for use with large scale multiplayer dedicated game server deployments, to ensure security, access control, telemetry data, metrics and more."
homepage = "https://github.com/googleforgames/quilkin"
repository = "https://github.com/googleforgames/quilkin"
readme = "README.md"
keywords = ["proxy", "game-server", "game-development", "networking", "multiplayer"]
categories = ["game-development", "network-programming"]
edition = "2018"
edition.workspace = true

[lib]
proc-macro = true
Expand Down
2 changes: 1 addition & 1 deletion crates/proto-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[package]
name = "proto-gen"
version = "0.1.0"
edition = "2021"
edition.workspace = true
publish = false

[[bin]]
Expand Down
8 changes: 6 additions & 2 deletions crates/proto-gen/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use std::{
process::{Command, Stdio},
};

const VERSION: &str = "0.2.6";
// The proto-gen version to use, installing if needed
const VERSION: &str = "0.3.0";

fn check_version(name: &str, prefix: &str, wanted: &str) -> bool {
if let Ok(output) = Command::new(name).arg("--version").output() {
Expand All @@ -31,7 +32,9 @@ fn check_version(name: &str, prefix: &str, wanted: &str) -> bool {
if v == wanted {
return true;
} else {
println!("{name} version detected as '{v}' which did not match expected version '{wanted}'");
println!(
"{name} version detected as '{v}' which did not match expected version '{wanted}'"
);
}
}
} else {
Expand Down Expand Up @@ -219,6 +222,7 @@ fn execute(which: &str) {
cmd
// Run rustfmt on the output, since they're committed they might as well be nice
.arg("--format")
.arg("2024")
.arg("--build-server")
.arg("--build-client")
.arg("--generate-transport")
Expand Down
Loading

0 comments on commit d4733c5

Please sign in to comment.