Skip to content

Commit

Permalink
Merge branch 'main' into 1271
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Jun 7, 2024
2 parents 2b9b5ad + bdd16df commit b5a499a
Show file tree
Hide file tree
Showing 83 changed files with 2,347 additions and 232 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:

- name: Cache NASM
if: runner.os == 'Windows'
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
nasm-2.16.02
Expand Down
56 changes: 28 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ opentelemetry-otlp = { version = "0.16.0", features = [
# required to make grpc requests
"tls-roots",
], optional = true }
opentelemetry-system-metrics = { version = "0.1.9", optional = true }
opentelemetry-system-metrics = { version = "0.2.0", optional = true }
tailcall-http-cache = { path = "tailcall-http-cache", optional = true }
tailcall-version = { path = "./tailcall-version", optional = true }

Expand Down Expand Up @@ -250,3 +250,8 @@ harness = false
[[test]]
name = "execution_spec"
harness = false

[[test]]
name = "json_to_config_spec"
path = "src/core/generator/tests/json_to_config_spec.rs"
harness = false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Head out to [docs] to learn about other powerful tailcall features.

Your contributions are invaluable! Kindly go through our [contribution guidelines] if you are a first time contributor.

[contribution guidelines]: https://tailcall.run/docs/contributors/
[contribution guidelines]: https://tailcall.run/developers/

### Support Us

Expand Down
3 changes: 2 additions & 1 deletion benches/data_loader_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use hyper::body::Bytes;
use reqwest::Request;
use tailcall::core::config::Batch;
use tailcall::core::http::{DataLoaderRequest, HttpDataLoader, Response};
use tailcall::core::ir::IoId;
use tailcall::core::runtime::TargetRuntime;
use tailcall::core::{EnvIO, FileIO, HttpIO};

Expand Down Expand Up @@ -50,7 +51,7 @@ impl FileIO for File {
struct Cache;
#[async_trait::async_trait]
impl tailcall::core::Cache for Cache {
type Key = u64;
type Key = IoId;
type Value = ConstValue;

async fn set<'a>(&'a self, _: Self::Key, _: Self::Value, _: NonZeroU64) -> anyhow::Result<()> {
Expand Down
32 changes: 32 additions & 0 deletions benches/from_json_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use criterion::Criterion;
use hyper::Method;
use serde_json::Value;
use tailcall::cli::runtime::NativeHttp;
use tailcall::core::generator::{from_json, ConfigGenerationRequest};
use tailcall::core::HttpIO;

pub fn benchmark_from_json_method(c: &mut Criterion) {
let tokio_runtime = tokio::runtime::Runtime::new().unwrap();

let native_http = NativeHttp::init(&Default::default(), &Default::default());
let request_url = String::from("http://jsonplaceholder.typicode.com/users");

let mut reqs = Vec::with_capacity(1);
tokio_runtime.block_on(async {
let request = reqwest::Request::new(Method::GET, request_url.parse().unwrap());
let result = native_http.execute(request).await.unwrap();
let body: Value = serde_json::from_slice(&result.body).unwrap();
reqs.push(body);
});

let cfg_gen_reqs = [ConfigGenerationRequest::new(
request_url.parse().unwrap(),
reqs[0].clone(),
)];

c.bench_function("from_json_bench", |b| {
b.iter(|| {
let _ = from_json(&cfg_gen_reqs, "Query");
});
});
}
2 changes: 2 additions & 0 deletions benches/tailcall_benches.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use criterion::{criterion_group, criterion_main, Criterion};

mod data_loader_bench;
mod from_json_bench;
mod handle_request_bench;
mod http_execute_bench;
mod impl_path_string_for_evaluation_context;
Expand All @@ -17,6 +18,7 @@ fn all_benchmarks(c: &mut Criterion) {
request_template_bench::benchmark_to_request(c);
handle_request_bench::benchmark_handle_request(c);
http_execute_bench::benchmark_http_execute_method(c);
from_json_bench::benchmark_from_json_method(c);
}

criterion_group! {
Expand Down
12 changes: 6 additions & 6 deletions npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cli/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub enum Command {
Gen {
/// Path of the source files separated by spaces if more than one
#[arg(required = true)]
file_paths: Vec<String>,
paths: Vec<String>,

/// Format of the input file
#[clap(short, long)]
Expand Down
5 changes: 2 additions & 3 deletions src/cli/tc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::core::generator::Generator;
use crate::core::http::API_URL_PREFIX;
use crate::core::print_schema;
use crate::core::rest::{EndpointSet, Unchecked};

const FILE_NAME: &str = ".tailcallrc.graphql";
const YML_FILE_NAME: &str = ".graphqlrc.yml";
const JSON_FILE_NAME: &str = ".tailcallrc.schema.json";
Expand Down Expand Up @@ -82,10 +81,10 @@ pub async fn run() -> Result<()> {
}
}
Command::Init { folder_path } => init(&folder_path).await,
Command::Gen { file_paths, input, output, query } => {
Command::Gen { paths, input, output, query } => {
let generator = Generator::init(runtime);
let cfg = generator
.read_all(input, file_paths.as_ref(), query.as_str())
.read_all(input, paths.as_ref(), query.as_str())
.await?;

let config = output.unwrap_or_default().encode(&cfg)?;
Expand Down
Loading

1 comment on commit b5a499a

@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.71ms 3.62ms 136.50ms 79.57%
Req/Sec 3.80k 192.14 4.24k 92.08%

453344 requests in 30.01s, 2.27GB read

Requests/sec: 15108.09

Transfer/sec: 77.54MB

Please sign in to comment.