Skip to content

Commit

Permalink
feat: implement topology for all pool types (#1225)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->
Fixes RVTEE-69
## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
MasterPtato committed Oct 22, 2024
1 parent 0bea10f commit f659729
Show file tree
Hide file tree
Showing 26 changed files with 565 additions and 207 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ members = [
"svc/pkg/token/ops/revoke/",
"svc/pkg/token/ops/get/",
"svc/pkg/token/ops/create/",
"svc/pkg/game-node/",
"svc/pkg/server-spec/",
"svc/pkg/nsfw/util/",
"svc/pkg/nsfw/ops/image-score/",
"svc/pkg/cluster/",
Expand Down
2 changes: 1 addition & 1 deletion lib/global-error/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl ToGlobalError for reqwest::Response {
let status = self.status();
let body = self.text().await?;

bail!(format!("{url} ({status}):\n{body}"));
bail!("{url} ({status}):\n{body}");
}
}
}
82 changes: 12 additions & 70 deletions lib/global-error/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,9 @@ pub use err_code;
/// ```
#[macro_export]
macro_rules! bail {
($msg:expr) => {
($($fmt_arg:tt)+) => {
return Err(Into::into($crate::ext::AssertionError::Panic {
message: Into::<String>::into($msg),
location: $crate::location!(),
}));
};
($fmt:expr, $($arg:tt)*) => {
return Err(Into::into($crate::ext::AssertionError::Panic {
message: format!($fmt, $($arg)*),
message: format!($($fmt_arg)+),
location: $crate::location!(),
}));
};
Expand All @@ -121,24 +115,9 @@ pub use bail;
/// ```
#[macro_export]
macro_rules! retry_bail {
($msg:expr) => {{
($($fmt_arg:tt)+) => {{
let mut err = GlobalError::from($crate::ext::RetryError {
message: Into::<String>::into($msg),
location: $crate::location!(),
});
if let GlobalError::Internal {
ref mut retry_immediately,
..
} = err
{
*retry_immediately = true;
}

return Err(err);
}};
($fmt:expr, $($arg:tt)*) => {{
let mut err = GlobalError::from($crate::ext::RetryError {
message: format!($fmt, $($arg)*),
message: format!($($fmt_arg)+),
location: $crate::location!(),
});
if let GlobalError::Internal {
Expand Down Expand Up @@ -175,22 +154,12 @@ pub use retry_bail;
/// ```
#[macro_export]
macro_rules! ensure {
($expr:expr, $msg:expr) => {{
let val = $expr;
if !val {
return Err(Into::into($crate::ext::AssertionError::Assert {
val: format!("{:?}", val),
message: Into::<String>::into($msg),
location: $crate::location!(),
}));
}
}};
($expr:expr, $fmt:expr, $($arg:tt)*) => {{
($expr:expr, $($fmt_arg:tt)+) => {{
let val = $expr;
if !val {
return Err(Into::into($crate::ext::AssertionError::Assert {
val: format!("{:?}", val),
message: format!($fmt, $($arg)*),
message: format!($($fmt_arg)+),
location: $crate::location!(),
}));
}
Expand Down Expand Up @@ -222,28 +191,14 @@ pub use ensure;
/// ```
#[macro_export]
macro_rules! ensure_eq {
($left:expr, $right:expr, $msg:expr) => {{
($left:expr, $right:expr, $($fmt_arg:tt)+) => {{
match (&$left, &$right) {
(val_left, val_right) => {
if !(*val_left == *val_right) {
return Err(Into::into($crate::ext::AssertionError::AssertEq {
val_left: format!("{:?}", val_left),
val_right: format!("{:?}", val_right),
message: Into::<String>::into($msg),
location: $crate::location!(),
}));
}
}
}
}};
($left:expr, $right:expr, $fmt:expr, $($arg:tt)*) => {{
match (&$left, &$right) {
(val_left, val_right) => {
if !(*val_left == *val_right) {
return Err(Into::into($crate::ext::AssertionError::AssertEq {
val_left: format!("{:?}", val_left),
val_right: format!("{:?}", val_right),
message: format!($fmt, $($arg)*),
message: format!($($fmt_arg)+),
location: $crate::location!(),
}));
}
Expand Down Expand Up @@ -278,11 +233,8 @@ pub use ensure_eq;
/// ```
#[macro_export]
macro_rules! unwrap_ref {
($expr:expr, $msg:expr) => {{
$crate::unwrap!(&$expr, $msg)
}};
($expr:expr, $fmt:expr, $($arg:tt)*) => {{
$crate::unwrap!(&$expr, format!($fmt, $($arg)*))
($expr:expr, $($fmt_arg:tt)+) => {{
$crate::unwrap!(&$expr, $($fmt_arg)+)
}};
($expr:expr $(,)?) => {{
$crate::unwrap!(&$expr)
Expand Down Expand Up @@ -312,20 +264,10 @@ pub use unwrap_ref;
/// ```
#[macro_export]
macro_rules! unwrap {
($expr:expr, $msg:expr) => {{
match $crate::ext::UnwrapOrAssertError::assertion_error_unwrap(
$expr,
Into::<String>::into($msg),
$crate::location!(),
) {
Ok(val) => val,
Err(err) => return Err(err.into()),
}
}};
($expr:expr, $fmt:expr, $($arg:tt)*) => {{
($expr:expr, $($fmt_arg:tt)+) => {{
match $crate::ext::UnwrapOrAssertError::assertion_error_unwrap(
$expr,
format!($fmt, $($arg)*),
format!($($fmt_arg)+),
$crate::location!(),
) {
Ok(val) => val,
Expand Down
3 changes: 2 additions & 1 deletion svc/pkg/cluster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ rivet-operation = { path = "../../../lib/operation/core" }
rivet-runtime = { path = "../../../lib/runtime" }
s3-util = { path = "../../../lib/s3-util" }
serde = { version = "1.0.198", features = ["derive"] }
serde_urlencoded = "0.7.0"
ssh2 = "0.9.4"
strum = { version = "0.24", features = ["derive"] }
trust-dns-resolver = { version = "0.23.2", features = ["dns-over-native-tls"] }

ip-info = { path = "../ip/ops/info" }
linode = { path = "../linode" }
game-node = { path = "../game-node" }
server-spec = { path = "../server-spec" }
pegboard = { path = "../pegboard" }
token-create = { path = "../token/ops/create" }

Expand Down
Loading

0 comments on commit f659729

Please sign in to comment.