Skip to content

Commit

Permalink
refactor: use display macro instead of manual implementation (#2133)
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill authored Jun 7, 2024
1 parent 23f4ba2 commit 7a1fb8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ which = { version = "6.0.1", optional = true }
async-recursion = "1.1.1"
tempfile = "3.10.1"
rquickjs = { "version" = "0.5.1", optional = true, features = ["macro"] }
strum_macros = "0.26.2"
strum_macros = "0.26.4"
# TODO: disable some levels with features?
tracing = { workspace = true }
tracing-subscriber = { version = "0.3.18", features = [
Expand Down
19 changes: 4 additions & 15 deletions src/core/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod modify;
mod resolver_context_like;

use core::future::Future;
use std::fmt::{Debug, Display};
use std::fmt::Debug;
use std::pin::Pin;

use async_graphql_value::ConstValue;
Expand All @@ -19,34 +19,23 @@ pub use evaluation_context::EvaluationContext;
pub use graphql_operation_context::GraphQLOperationContext;
pub use io::*;
pub use resolver_context_like::{EmptyResolverContext, ResolverContext, ResolverContextLike};
use strum_macros::Display;

use crate::core::blueprint::DynamicValue;
use crate::core::json::JsonLike;
use crate::core::serde_value_ext::ValueExt;

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Display)]
pub enum IR {
Context(Context),
Dynamic(DynamicValue),
#[strum(to_string = "{0}")]
IO(IO),
Cache(Cache),
Path(Box<IR>, Vec<String>),
Protect(Box<IR>),
}

impl Display for IR {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
IR::Context(_) => write!(f, "Context"),
IR::Dynamic(_) => write!(f, "Literal"),
IR::IO(io) => write!(f, "{io}"),
IR::Cache(_) => write!(f, "Cache"),
IR::Path(_, _) => write!(f, "Input"),
IR::Protect(expr) => write!(f, "Protected({expr})"),
}
}
}

#[derive(Clone, Debug)]
pub enum Context {
Value,
Expand Down

1 comment on commit 7a1fb8a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 6.70ms 3.49ms 146.08ms 77.96%
Req/Sec 3.80k 224.05 4.35k 93.67%

453384 requests in 30.01s, 2.27GB read

Requests/sec: 15108.98

Transfer/sec: 77.55MB

Please sign in to comment.