Skip to content

Commit

Permalink
chore(grpc): move rust-grpc example into main repo (#1777)
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill authored Apr 27, 2024
1 parent 7e62b6b commit 0f90d81
Show file tree
Hide file tree
Showing 29 changed files with 658 additions and 155 deletions.
11 changes: 3 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
/.vscode
.DS_Store
.bsp
/cloudflare/node_modules
/cloudflare/.wrangler
# direnv
.direnv
.envrc
.env

npm/@tailcallhq
npm/node_modules

cloudflare/.wrangler
cloudflare/build
cloudflare/node_modules
cloudflare/pkg
node_modules/

# cloudflare
.wrangler/
tailcall-/cloudflare/build

*.snap.new
136 changes: 135 additions & 1 deletion Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ insta = { workspace = true }
tempfile = "3.10.1"
temp-env = "0.3.6"
maplit = "1.0.2"
tailcall-fixtures = { path = "./tailcall-fixtures" }

[features]

Expand Down Expand Up @@ -201,6 +202,8 @@ members = [
"tailcall-macros",
"tailcall-prettier",
"tailcall-query-plan",
"tailcall-fixtures",
"tailcall-upstream-grpc"
]

# Boost execution_spec snapshot diffing performance
Expand Down
9 changes: 8 additions & 1 deletion examples/grpc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
schema
@server(port: 8000, graphiql: true)
@upstream(baseURL: "http://localhost:50051", httpCache: true, batch: {delay: 10})
@link(id: "news", src: "../src/grpc/tests/proto/news.proto", type: Protobuf) {
@link(id: "news", src: "../tailcall-fixtures/fixtures/protobuf/news.proto", type: Protobuf) {
query: Query
}

Expand All @@ -18,6 +18,13 @@ type News {
title: String
body: String
postImage: String
status: Status
}

enum Status {
PUBLISHED
DRAFT
DELETED
}

input NewsInput {
Expand Down
9 changes: 8 additions & 1 deletion examples/telemetry-otlp.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ schema
@server(port: 8000, graphiql: true, hostname: "0.0.0.0")
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true)
@link(type: Operation, src: "operations/routes.graphql")
@link(id: "news", src: "../src/grpc/tests/proto/news.proto", type: Protobuf)
@link(id: "news", src: "../tailcall-fixtures/fixtures/protobuf/news.proto", type: Protobuf)
@telemetry(
export: {
otlp: {
Expand Down Expand Up @@ -48,6 +48,13 @@ type News {
title: String
body: String
postImage: String
status: Status
}

enum Status {
PUBLISHED
DRAFT
DELETED
}

type NewsData {
Expand Down
12 changes: 3 additions & 9 deletions src/grpc/data_loader_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ impl DataLoaderRequest {
#[cfg(test)]
mod tests {
use std::collections::BTreeSet;
use std::path::PathBuf;

use hyper::header::{HeaderName, HeaderValue};
use hyper::HeaderMap;
use pretty_assertions::assert_eq;
use tailcall_fixtures::protobuf;
use url::Url;

use super::DataLoaderRequest;
Expand All @@ -68,16 +68,10 @@ mod tests {
use crate::grpc::request_template::RenderedRequestTemplate;

pub async fn get_protobuf_op() -> ProtobufOperation {
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut test_file = root_dir.join(file!());

test_file.pop();
test_file.push("tests");
test_file.push("proto");
test_file.push("greetings.proto");
let test_file = protobuf::GREETINGS;
let mut config = Config::default().links(vec![Link {
id: None,
src: test_file.to_str().unwrap().to_string(),
src: test_file.to_string(),
type_of: LinkType::Protobuf,
}]);
let method = GrpcMethod {
Expand Down
Loading

1 comment on commit 0f90d81

@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 7.71ms 3.59ms 109.97ms 73.00%
Req/Sec 3.29k 262.64 4.28k 85.75%

392898 requests in 30.02s, 1.97GB read

Requests/sec: 13087.78

Transfer/sec: 67.18MB

Please sign in to comment.