Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 21 additions & 2 deletions packages/common/api-helper/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ENDPOINT_ARGUMENTS: &[&str] = &[
];

struct EndpointRouter {
name: Option<syn::Ident>,
routes: Punctuated<Endpoint, Token![,]>,
cors_config: Option<syn::Expr>,
mounts: Punctuated<Mount, Token![,]>,
Expand All @@ -44,6 +45,7 @@ struct EndpointRouter {

impl Parse for EndpointRouter {
fn parse(input: ParseStream) -> syn::Result<Self> {
let mut name = None;
let mut routes = None;
let mut cors_config = None;
let mut mounts = None;
Expand All @@ -60,6 +62,16 @@ impl Parse for EndpointRouter {

// Parse various keys
match key.to_string().as_str() {
"name" => {
if name.is_none() {
name = Some(input.parse()?);
} else {
return Err(syn::Error::new(
key.span(),
format!("Duplicate key `{}`.", key),
));
}
}
"routes" => {
if routes.is_none() {
let routes_content;
Expand Down Expand Up @@ -134,6 +146,7 @@ impl Parse for EndpointRouter {
let mounts = mounts.unwrap_or_default();

Ok(EndpointRouter {
name,
routes,
cors_config,
mounts,
Expand All @@ -144,6 +157,12 @@ impl Parse for EndpointRouter {

impl EndpointRouter {
fn render(self) -> syn::Result<TokenStream2> {
let name = if let Some(name) = self.name {
name.to_token_stream()
} else {
quote! { Router }
};

let endpoints = self
.routes
.into_iter()
Expand Down Expand Up @@ -186,8 +205,8 @@ impl EndpointRouter {
.collect::<Vec<_>>();

Ok(quote! {
pub struct Router;
impl Router {
pub struct #name;
impl #name {
#[doc(hidden)]
#[tracing::instrument(level="debug", name = "router_matcher", skip_all)]
pub async fn __inner(
Expand Down
2 changes: 2 additions & 0 deletions packages/common/fdb-util/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub const IMAGE_ID: usize = 52;
pub const ACTOR2: usize = 53;
pub const PENDING_ACTOR: usize = 54;
pub const PENDING_ACTOR_BY_IMAGE_ID: usize = 55;
pub const CONTAINER: usize = 56;

// Directories with fdbrs must use string paths instead of tuples
pub mod dir {
Expand Down Expand Up @@ -120,6 +121,7 @@ pub fn key_from_str(key: &str) -> Option<usize> {
"actor2" => Some(ACTOR2),
"pending_actor" => Some(PENDING_ACTOR),
"pending_actor_by_image_id" => Some(PENDING_ACTOR_BY_IMAGE_ID),
"container" => Some(CONTAINER),
_ => None,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name = "CONTAINER_FAILED_TO_CREATE"
description = "Container failed to create: {error}"
description_basic = "Container failed to create."
http_status = 400
---

# Container Failed To Create

Container failed to create.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "CONTAINER_LOGS_INVALID_CONTAINER_IDS"
description = "Invalid container IDs format."
http_status = 400
---

# Invalid Container Ids

The provided list of container IDs is not in a valid JSON format. Please provide a valid JSON array of UUIDs.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "CONTAINER_LOGS_NO_CONTAINER_IDS"
description = "No container IDs provided."
http_status = 400
---

# No Container Ids

No container IDs were provided in the request. Please provide at least one valid container ID.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "CONTAINER_LOGS_NO_VALID_CONTAINER_IDS"
description = "No valid container IDs found."
http_status = 400
---

# No Valid Container Ids

None of the provided container IDs are valid for this game/environment. Please provide valid container IDs.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "CONTAINER_METRICS_INVALID_INTERVAL"
description = "Invalid interval provided."
http_status = 400
---

# Invalid Interval

The provided interval must be greater than 0. Please provide a valid interval value in milliseconds.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "CONTAINER_METRICS_INVALID_METRICS"
description = "Invalid metrics format."
http_status = 400
---

# Invalid Metrics

The provided list of metrics is not in a valid JSON format. Please provide a valid JSON array of metric names.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "CONTAINER_METRICS_NO_METRICS"
description = "No metrics specified."
http_status = 400
---

# No Metrics

No metrics were specified in the request. Please provide at least one metric name to query.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "CONTAINER_METRICS_UNSUPPORTED_METRICS"
description = "Unsupported metrics requested."
http_status = 400
---

# Unsupported Metrics

The requested metrics are not supported. Supported metrics include: cpu, memory, memory_limit, network_rx_bytes, network_tx_bytes.
9 changes: 9 additions & 0 deletions packages/common/formatted-error/errors/container/not-found.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "CONTAINER_NOT_FOUND"
description = "Container not found."
http_status = 400
---

# Container Not Found

Container not found for the given ID.
4 changes: 1 addition & 3 deletions packages/common/pools/src/db/sqlite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,7 @@ impl SqlitePoolManager {
.sum::<usize>() as f64;

// Update state if write was successful
for (key_packed, data) in db_data_to_snapshot {
let hex_key = hex::encode(&**key_packed);

for (_, data) in db_data_to_snapshot {
// Because this was batch processed we don't know the rate for each individual key, just estimate
// by calculating the size ratio
let ratio = data.len() as f64 / total_data_size;
Expand Down
7 changes: 4 additions & 3 deletions packages/common/util/id/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub enum IdError {

#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub enum Id {
// TODO: Once all old actors are gone, delete the v0 variant
V0(Uuid),
V1([u8; 18]),
}
Expand Down Expand Up @@ -237,7 +238,7 @@ impl TuplePack for Id {
fn pack<W: std::io::Write>(
&self,
w: &mut W,
tuple_depth: TupleDepth,
_tuple_depth: TupleDepth,
) -> std::io::Result<VersionstampOffset> {
let mut size = 1;

Expand All @@ -263,7 +264,7 @@ impl TuplePack for Id {
}

impl<'de> TupleUnpack<'de> for Id {
fn unpack(input: &[u8], tuple_depth: TupleDepth) -> PackResult<(&[u8], Self)> {
fn unpack(input: &[u8], _tuple_depth: TupleDepth) -> PackResult<(&[u8], Self)> {
let input = fdb_util::parse_code(input, fdb_util::codes::ID)?;
let (input2, version) = fdb_util::parse_byte(input)?;

Expand Down Expand Up @@ -336,7 +337,7 @@ impl sqlx::postgres::PgHasArrayType for Id {

impl Default for Id {
fn default() -> Self {
Id::V0(Uuid::new_v4())
Id::V1(Default::default())
}
}

Expand Down
Loading
Loading