Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blueprint): blueprint from Schema #3110

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benches/handle_request_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn benchmark_handle_request(c: &mut Criterion) {
let endpoints = config_module.extensions().endpoint_set.clone();
let endpoints_clone = endpoints.clone();

blueprint.server.enable_jit = false;
blueprint.config.server.enable_jit = false;
let server_config = tokio_runtime
.block_on(ServerConfig::new(blueprint.clone(), endpoints.clone()))
.unwrap();
Expand All @@ -47,7 +47,7 @@ pub fn benchmark_handle_request(c: &mut Criterion) {
})
});

blueprint_clone.server.enable_jit = true;
blueprint_clone.config.server.enable_jit = true;
let server_config = tokio_runtime
.block_on(ServerConfig::new(blueprint_clone, endpoints_clone))
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions benches/http_execute_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub fn benchmark_http_execute_method(c: &mut Criterion) {
let tokio_runtime = tokio::runtime::Runtime::new().unwrap();

let mut blueprint = Blueprint::default();
blueprint.upstream.http_cache = 42; // allow http caching for bench test.
let native_http = NativeHttp::init(&blueprint.upstream, &blueprint.telemetry);
blueprint.config.upstream.http_cache = 42; // allow http caching for bench test.
let native_http = NativeHttp::init(&blueprint.config.upstream, &blueprint.config.telemetry);
let request_url = String::from("http://jsonplaceholder.typicode.com/users");

tokio_runtime.block_on(async {
Expand Down
8 changes: 4 additions & 4 deletions benches/impl_path_string_for_evaluation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use indexmap::IndexMap;
use once_cell::sync::Lazy;
use reqwest::{Client, Request};
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use tailcall::core::blueprint::{Server, Upstream};
use tailcall::core::cache::InMemoryCache;
use tailcall::core::config::{ServerRuntime, UpstreamRuntime};
use tailcall::core::http::{RequestContext, Response};
use tailcall::core::ir::{EvalContext, ResolverContextLike, SelectionField};
use tailcall::core::path::PathString;
Expand All @@ -28,7 +28,7 @@ struct Http {
}

impl Http {
fn init(upstream: &Upstream) -> Self {
fn init(upstream: &UpstreamRuntime) -> Self {
let mut builder = Client::builder()
.tcp_keepalive(Some(Duration::from_secs(upstream.tcp_keep_alive)))
.timeout(Duration::from_secs(upstream.timeout))
Expand Down Expand Up @@ -238,8 +238,8 @@ fn request_context() -> RequestContext {
let config_module = tailcall::core::config::ConfigModule::default();

//TODO: default is used only in tests. Drop default and move it to test.
let upstream = Upstream::try_from(&config_module).unwrap();
let server = Server::try_from(config_module).unwrap();
let upstream = UpstreamRuntime::try_from(&config_module).unwrap();
let server = ServerRuntime::try_from(config_module).unwrap();
let http = Arc::new(Http::init(&upstream));
let http2 = Arc::new(Http::init(&upstream.clone().http2_only(true)));
let runtime = TargetRuntime {
Expand Down
80 changes: 46 additions & 34 deletions generated/.tailcallrc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ directive, developers gain access to valuable insights into the performance and
of their applications.
"""
directive @telemetry(
export: TelemetryExporter
export: TelemetryExporterConfig
"""
The list of headers that will be sent as additional attributes to telemetry exporters
Be careful about **leaking sensitive information** from requests when enabling the
Expand Down Expand Up @@ -628,43 +628,43 @@ input Schema {
"""
Type to configure Cross-Origin Resource Sharing (CORS) for a server.
"""
input Cors {
input CorsStatic {
"""
Indicates whether the server allows credentials (e.g., cookies, authorization headers)
to be sent in cross-origin requests.
"""
allowCredentials: Boolean
allow_credentials: Boolean
"""
A list of allowed headers in cross-origin requests. This can be used to specify custom
headers that are allowed to be included in cross-origin requests.
"""
allowHeaders: [String!]
allow_headers: [String!]
"""
A list of allowed HTTP methods in cross-origin requests. These methods specify the
actions that are permitted in cross-origin requests.
"""
allowMethods: [Method]
allow_methods: [Method]
"""
A list of origins that are allowed to access the server's resources in cross-origin
requests. An origin can be a domain, a subdomain, or even 'null' for local file schemes.
"""
allowOrigins: [String!]
allow_origins: [String!]
"""
Indicates whether requests from private network addresses are allowed in cross-origin
requests. Private network addresses typically include IP addresses reserved for internal
networks.
"""
allowPrivateNetwork: Boolean
allow_private_network: Boolean
"""
A list of headers that the server exposes to the browser in cross-origin responses.
Exposing certain headers allows the client-side code to access them in the response.
"""
exposeHeaders: [String!]
expose_headers: [String!]
"""
The maximum time (in seconds) that the client should cache preflight OPTIONS requests
in order to avoid sending excessive requests to the server.
"""
maxAge: Int
max_age: Int
"""
A list of header names that indicate the values of which might cause the server's
response to vary, potentially affecting caching.
Expand All @@ -674,16 +674,16 @@ input Cors {

input Headers {
"""
`cacheControl` sends `Cache-Control` headers in responses when activated. The `max-age`
`cache_control` sends `Cache-Control` headers in responses when activated. The `max-age`
value is the least of the values received from upstream services. @default `false`.
"""
cacheControl: Boolean
cache_control: Boolean
"""
`cors` allows Cross-Origin Resource Sharing (CORS) for a server.
"""
cors: Cors
cors: CorsStatic
"""
`headers` are key-value pairs included in every server response. Useful for setting
`custom` are key-value pairs included in every server response. Useful for setting
headers like `Access-Control-Allow-Origin` for cross-origin requests or additional
headers for downstream services.
"""
Expand All @@ -694,38 +694,47 @@ input Headers {
"""
experimental: [String!]
"""
`setCookies` when enabled stores `set-cookie` headers and all the response will be
sent with the headers.
`set_cookies` when enabled stores `set-cookie` headers and all the response will
be sent with the headers.
"""
setCookies: Boolean
set_cookies: Boolean
}

"""
Used to configure the default routes of the server.
"""
input Routes {
graphQL: String!
"""
The path for the GraphQL endpoint. Defaults to `/graphql`.
"""
graphql: String!
"""
The path for the status endpoint. Defaults to `/status`.
"""
status: String!
}

input ScriptOptions {
timeout: Int
}

input Apollo {
input ApolloTelemetry {
"""
Setting `apiKey` for Apollo.
Setting `api_key` for Apollo.
"""
apiKey: String!
api_key: String!
"""
Setting `graphRef` for Apollo in the format <graphId>@<variant>.
Setting `graph_ref` for Apollo in the format <graphId>@<variant>.
"""
graphRef: String!
graph_ref: String!
"""
Setting `platform` for Apollo.
"""
platform: String
"""
Setting `userVersion` for Apollo.
Setting `user_version` for Apollo.
"""
userVersion: String
user_version: String
"""
Setting `version` for Apollo.
"""
Expand All @@ -735,7 +744,7 @@ input Apollo {
"""
Output the opentelemetry data to otlp collector
"""
input OtlpExporter {
input OtlpExporterConfig {
headers: [KeyValue]
url: String!
}
Expand All @@ -758,17 +767,17 @@ input StdoutExporter {
pretty: Boolean!
}

input TelemetryExporter {
stdout: StdoutExporter
otlp: OtlpExporter
prometheus: PrometheusExporter
apollo: Apollo
input TelemetryExporterConfig {
Stdout: StdoutExporter
Otlp: OtlpExporterConfig
Prometheus: PrometheusExporter
Apollo: ApolloTelemetry
}

input Batch {
delay: Int!
headers: [String!]
maxSize: Int
max_size: Int
}

input Proxy {
Expand Down Expand Up @@ -984,7 +993,7 @@ directive, developers gain access to valuable insights into the performance and
of their applications.
"""
input Telemetry {
export: TelemetryExporter
export: TelemetryExporterConfig
"""
The list of headers that will be sent as additional attributes to telemetry exporters
Be careful about **leaking sensitive information** from requests when enabling the
Expand All @@ -1010,6 +1019,9 @@ enum Method {
TRACE
}

"""
The acceptable types of linked files that can be loaded on bootstrap.
"""
enum LinkType {
Config
Protobuf
Expand All @@ -1031,6 +1043,6 @@ enum HttpVersion {
Output format for prometheus data
"""
enum PrometheusFormat {
text
protobuf
Text
Protobuf
}
Loading
Loading