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

chore: restructure workspace #1887

Merged
merged 52 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
7cc04bc
- moved all modules except cli to core.
laststylebender14 May 6, 2024
3e98456
- moved main entry point to cli module.
laststylebender14 May 6, 2024
05d16a2
- updated the binary and lib path in toml file.
laststylebender14 May 6, 2024
75f0fed
- updated path of reflection proto.
laststylebender14 May 6, 2024
08b41c3
- use cli and core as lib.
laststylebender14 May 6, 2024
c9e99ce
- updated imports for tests.
laststylebender14 May 6, 2024
b509726
- updated snaps as the only source path is changed.
laststylebender14 May 6, 2024
df90ff7
- since the contents of lib.rs are moved to mod.rs file. hence removi…
laststylebender14 May 6, 2024
10a18f0
- updated import path for tailcall-autogen.
laststylebender14 May 6, 2024
cdd47ec
- updated import path for tailcall-aws-lamba
laststylebender14 May 6, 2024
2136209
- updated import path for tailcall-cloudflare.
laststylebender14 May 6, 2024
9b56f24
- updated import path for tailcall-query-plan.
laststylebender14 May 6, 2024
a3d7bc0
Merge branch 'main' into chore/restructure-workspace
laststylebender14 May 6, 2024
3fa754c
- fixed the path for cache.
laststylebender14 May 6, 2024
6b36925
- lint changes.
laststylebender14 May 6, 2024
53aaef3
- updated import paths.
laststylebender14 May 6, 2024
60b2642
- allow module_inception lint error for now.
laststylebender14 May 6, 2024
ba7b2a8
- removed unnecessary explicit mention of lib.
laststylebender14 May 6, 2024
6d582df
rename files
tusharmath May 7, 2024
54d8525
- made core private.
laststylebender14 May 7, 2024
4b9a0d4
- reexport the modules and fuctions that are required outside.
laststylebender14 May 7, 2024
2c8ef31
- updated import path.
laststylebender14 May 7, 2024
f152669
- lint changes.
laststylebender14 May 7, 2024
1305caa
- removed unused impl declartion.
laststylebender14 May 7, 2024
94ba54a
- moved code to test module as it's only used in test.
laststylebender14 May 7, 2024
dd2b464
- lint changes.
laststylebender14 May 7, 2024
8a3964b
- lint all caps issue fix.
laststylebender14 May 7, 2024
d237491
- lint: wrong_self_convention fixes.
laststylebender14 May 7, 2024
993182a
- moved succed to tests as it's not being used anywhere.
laststylebender14 May 7, 2024
cb647cd
- moved HashMapCache<S> constructor to test module as it's being used…
laststylebender14 May 7, 2024
c516c6b
- lint: wrong_self_convention fixes.
laststylebender14 May 7, 2024
935bd32
- lint: wrong_self_convention fixes.
laststylebender14 May 7, 2024
6616cc6
- disabled lint upper_case_acronyms for JSON.
laststylebender14 May 7, 2024
0b4ad93
- moved test related functions into test module.
laststylebender14 May 7, 2024
1d4bdec
- disabled lint error fo to_const_directive, as it's being used in Di…
laststylebender14 May 7, 2024
f1d5d22
Merge branch 'chore/restructure-workspace' of https://github.com/ranj…
laststylebender14 May 7, 2024
721631e
- lint changes.
laststylebender14 May 7, 2024
cd70cf3
Merge branch 'main' into chore/restructure-workspace
laststylebender14 May 7, 2024
84afe94
- updated snap.
laststylebender14 May 7, 2024
e22f3c0
- allow dead code temporary.
laststylebender14 May 7, 2024
a5402b2
- remove unused import.
laststylebender14 May 7, 2024
a401d55
Merge branch 'main' into chore/restructure-workspace
laststylebender14 May 7, 2024
9495014
Merge branch 'main' into chore/restructure-workspace
laststylebender14 May 8, 2024
f68354c
- lint changes.
laststylebender14 May 8, 2024
14d24d2
- use already exported Source from generator's mod file.
laststylebender14 May 8, 2024
ece3219
- export the imports from lib.
laststylebender14 May 8, 2024
68214eb
- lint changes.
laststylebender14 May 8, 2024
6df4ccf
Merge branch 'main' into chore/restructure-workspace
laststylebender14 May 8, 2024
615d5a0
- disable lint rule of dead code for scalar types.
laststylebender14 May 8, 2024
308fb91
- removed internals.rs file as it's no longer required.
laststylebender14 May 8, 2024
86b5f95
- removed as code was only being used in tests and had no impact on n…
laststylebender14 May 8, 2024
fe35af0
- lint changes.
laststylebender14 May 8, 2024
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
7 changes: 3 additions & 4 deletions benches/data_loader_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ use async_trait::async_trait;
use criterion::Criterion;
use hyper::body::Bytes;
use reqwest::Request;
use tailcall::config::Batch;
use tailcall::http::{DataLoaderRequest, HttpDataLoader, Response};
use tailcall::runtime::TargetRuntime;
use tailcall::{EnvIO, FileIO, HttpIO};
use tailcall::{
Batch, DataLoaderRequest, EnvIO, FileIO, HttpDataLoader, HttpIO, Response, TargetRuntime,
};

#[derive(Clone)]
struct MockHttpClient {
Expand Down
13 changes: 5 additions & 8 deletions benches/impl_path_string_for_evaluation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ use indexmap::IndexMap;
use once_cell::sync::Lazy;
use reqwest::{Client, Request};
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use tailcall::blueprint::{Server, Upstream};
use tailcall::cache::InMemoryCache;
use tailcall::http::{RequestContext, Response};
use tailcall::lambda::{EvaluationContext, ResolverContextLike};
use tailcall::path::PathString;
use tailcall::runtime::TargetRuntime;
use tailcall::{EnvIO, FileIO, HttpIO};
use tailcall::{
EnvIO, EvaluationContext, FileIO, HttpIO, InMemoryCache, PathString, RequestContext,
ResolverContextLike, Response, Server, TargetRuntime, Upstream,
};

struct Http {
client: ClientWithMiddleware,
Expand Down Expand Up @@ -231,7 +228,7 @@ fn assert_test(eval_ctx: &EvaluationContext<'_, MockGraphqlContext>) {
}

fn request_context() -> RequestContext {
let config_module = tailcall::config::ConfigModule::default();
let config_module = tailcall::ConfigModule::default();

//TODO: default is used only in tests. Drop default and move it to test.
let upstream = Upstream::try_from(&config_module).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions benches/json_like_bench.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{black_box, Criterion};
use serde_json::json;
use tailcall::json::JsonLike;
use tailcall::JsonLike;

pub fn benchmark_batched_body(c: &mut Criterion) {
c.bench_function("test_batched_body", |b| {
Expand All @@ -19,7 +19,7 @@ pub fn benchmark_batched_body(c: &mut Criterion) {
});

black_box(
serde_json::to_value(tailcall::json::gather_path_matches(
serde_json::to_value(tailcall::gather_path_matches(
&input,
&["data".into(), "user".into(), "id".into()],
vec![],
Expand Down
3 changes: 1 addition & 2 deletions benches/protobuf_convert_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use anyhow::Result;
use criterion::{black_box, Criterion};
use rand::{thread_rng, Fill};
use serde_json::{json, Value};
use tailcall::blueprint::GrpcMethod;
use tailcall::grpc::protobuf::ProtobufSet;
use tailcall::{GrpcMethod, ProtobufSet};

const PROTO_DIR: &str = "benches/grpc";
const PROTO_FILE: &str = "dummy.proto";
Expand Down
5 changes: 1 addition & 4 deletions benches/request_template_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use criterion::{black_box, Criterion};
use derive_setters::Setters;
use hyper::HeaderMap;
use serde_json::json;
use tailcall::endpoint::Endpoint;
use tailcall::has_headers::HasHeaders;
use tailcall::http::RequestTemplate;
use tailcall::path::PathString;
use tailcall::{Endpoint, HasHeaders, PathString, RequestTemplate};

#[derive(Setters)]
struct Context {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::{Parser, Subcommand};
use strum_macros::Display;

use crate::{config, generator};
use crate::core::{config, generator};

pub const VERSION: &str = match option_env!("APP_VERSION") {
Some(version) => version,
Expand Down
4 changes: 2 additions & 2 deletions src/cli/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use colored::Colorize;
use derive_setters::Setters;
use thiserror::Error;

use crate::valid::ValidationError;
use crate::core::valid::ValidationError;

#[derive(Debug, Error, Setters, PartialEq, Clone)]
pub struct CLIError {
Expand Down Expand Up @@ -236,7 +236,7 @@ mod tests {
use stripmargin::StripMargin;

use super::*;
use crate::valid::Cause;
use crate::core::valid::Cause;

#[test]
fn test_no_newline() {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use colored::*;

use crate::config::Config;
use crate::core::config::Config;

pub struct Fmt {}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/javascript/js_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use reqwest::Request;
use rquickjs::{FromJs, IntoJs};
use serde::{Deserialize, Serialize};

use crate::is_default;
use crate::core::is_default;

#[derive(Debug)]
pub struct JsRequest(reqwest::Request);
Expand Down
15 changes: 9 additions & 6 deletions src/cli/javascript/js_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use hyper::body::Bytes;
use rquickjs::{FromJs, IntoJs};

use super::create_header_map;
use crate::http::Response;
use crate::core::http::Response;

#[derive(Debug)]
pub struct JsResponse(Response<String>);
Expand Down Expand Up @@ -107,7 +107,7 @@ mod test {
fn create_test_response() -> Result<JsResponse> {
let mut headers = HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let response = crate::http::Response {
let response = crate::core::http::Response {
status: reqwest::StatusCode::OK,
headers,
body: Bytes::from("Hello, World!"),
Expand All @@ -132,7 +132,7 @@ mod test {
#[test]
fn test_from_js_response() {
let js_response = create_test_response().unwrap();
let response: Result<crate::http::Response<Bytes>> = js_response.try_into();
let response: Result<crate::core::http::Response<Bytes>> = js_response.try_into();
assert!(response.is_ok());
let response = response.unwrap();
assert_eq!(response.status, reqwest::StatusCode::OK);
Expand All @@ -151,11 +151,14 @@ mod test {
HeaderName::from_static("x-unusual-header"),
HeaderValue::from_str("🚀").unwrap(),
);
let response =
crate::http::Response { status: reqwest::StatusCode::OK, headers, body: body.into() };
let response = crate::core::http::Response {
status: reqwest::StatusCode::OK,
headers,
body: body.into(),
};
let js_response = JsResponse(response);

let response: Result<crate::http::Response<Bytes>, _> = js_response.try_into();
let response: Result<crate::core::http::Response<Bytes>, _> = js_response.try_into();
assert!(response.is_ok());
let response = response.unwrap();
assert_eq!(response.headers.get("x-unusual-header").unwrap(), "🚀");
Expand Down
2 changes: 1 addition & 1 deletion src/cli/javascript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub use js_response::JsResponse;
pub use request_filter::RequestFilter;
pub use runtime::Runtime;

use crate::{blueprint, HttpIO};
use crate::core::{blueprint, HttpIO};

pub fn init_http(
http: Arc<impl HttpIO>,
Expand Down
6 changes: 3 additions & 3 deletions src/cli/javascript/request_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use hyper::body::Bytes;
use rquickjs::FromJs;

use super::{JsRequest, JsResponse};
use crate::http::Response;
use crate::{HttpIO, WorkerIO};
use crate::core::http::Response;
use crate::core::{HttpIO, WorkerIO};

#[derive(Debug)]
pub enum Event {
Expand Down Expand Up @@ -106,7 +106,7 @@ mod tests {

use crate::cli::javascript::request_filter::Command;
use crate::cli::javascript::{JsRequest, JsResponse};
use crate::http::Response;
use crate::core::http::Response;

#[test]
fn test_command_from_invalid_object() {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/javascript/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rquickjs::{Context, Ctx, FromJs, Function, IntoJs, Value};

use super::request_filter::{Command, Event};
use super::JsRequest;
use crate::{blueprint, WorkerIO};
use crate::core::{blueprint, WorkerIO};

struct LocalRuntime(Context);

Expand Down
2 changes: 1 addition & 1 deletion src/cli/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};

use crate::runtime::TargetRuntime;
use crate::core::runtime::TargetRuntime;

fn cache_metrics(runtime: &TargetRuntime) -> Result<()> {
let meter = opentelemetry::global::meter("cache");
Expand Down
2 changes: 1 addition & 1 deletion src/cli/runtime/env.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::borrow::Cow;
use std::collections::HashMap;

use crate::EnvIO;
use crate::core::EnvIO;

#[derive(Clone)]
pub struct EnvNative {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/runtime/file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use tokio::io::{AsyncReadExt, AsyncWriteExt};

use crate::cli::CLIError;
use crate::FileIO;
use crate::core::FileIO;

#[derive(Clone)]
pub struct NativeFileIO {}
Expand Down
6 changes: 3 additions & 3 deletions src/cli/runtime/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use tracing_opentelemetry::OpenTelemetrySpanExt;

use super::HttpIO;
use crate::blueprint::telemetry::Telemetry;
use crate::blueprint::Upstream;
use crate::http::Response;
use crate::core::blueprint::telemetry::Telemetry;
use crate::core::blueprint::Upstream;
use crate::core::http::Response;

static HTTP_CLIENT_REQUEST_COUNT: Lazy<Counter<u64>> = Lazy::new(|| {
let meter = opentelemetry::global::meter("http_request");
Expand Down
8 changes: 4 additions & 4 deletions src/cli/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ mod http;
use std::hash::Hash;
use std::sync::Arc;

use crate::blueprint::Blueprint;
use crate::cache::InMemoryCache;
use crate::runtime::TargetRuntime;
use crate::{blueprint, EnvIO, FileIO, HttpIO};
use crate::core::blueprint::Blueprint;
use crate::core::cache::InMemoryCache;
use crate::core::runtime::TargetRuntime;
use crate::core::{blueprint, EnvIO, FileIO, HttpIO};

// Provides access to env in native rust environment
fn init_env() -> Arc<dyn EnvIO> {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/server/http_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use hyper::service::{make_service_fn, service_fn};
use tokio::sync::oneshot;

use super::server_config::ServerConfig;
use crate::async_graphql_hyper::{GraphQLBatchRequest, GraphQLRequest};
use crate::cli::CLIError;
use crate::http::handle_request;
use crate::core::async_graphql_hyper::{GraphQLBatchRequest, GraphQLRequest};
use crate::core::http::handle_request;

pub async fn start_http_1(
sc: Arc<ServerConfig>,
Expand Down
4 changes: 2 additions & 2 deletions src/cli/server/http_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use rustls_pki_types::{CertificateDer, PrivateKeyDer};
use tokio::sync::oneshot;

use super::server_config::ServerConfig;
use crate::async_graphql_hyper::{GraphQLBatchRequest, GraphQLRequest};
use crate::cli::CLIError;
use crate::http::handle_request;
use crate::core::async_graphql_hyper::{GraphQLBatchRequest, GraphQLRequest};
use crate::core::http::handle_request;

pub async fn start_http_2(
sc: Arc<ServerConfig>,
Expand Down
4 changes: 2 additions & 2 deletions src/cli/server/server.rs → src/cli/server/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use tokio::sync::oneshot::{self};
use super::http_1::start_http_1;
use super::http_2::start_http_2;
use super::server_config::ServerConfig;
use crate::blueprint::{Blueprint, Http};
use crate::cli::telemetry::init_opentelemetry;
use crate::cli::CLIError;
use crate::config::ConfigModule;
use crate::core::blueprint::{Blueprint, Http};
use crate::core::config::ConfigModule;

pub struct Server {
config_module: ConfigModule,
Expand Down
4 changes: 2 additions & 2 deletions src/cli/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub mod http_1;
pub mod http_2;
pub mod server;
pub mod http_server;
pub mod server_config;

pub use server::Server;
pub use http_server::Server;

use self::server_config::ServerConfig;

Expand Down
10 changes: 5 additions & 5 deletions src/cli/server/server_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::sync::Arc;

use async_graphql_extension_apollo_tracing::ApolloTracing;

use crate::blueprint::telemetry::TelemetryExporter;
use crate::blueprint::{Blueprint, Http};
use crate::cli::runtime::init;
use crate::http::AppContext;
use crate::rest::{EndpointSet, Unchecked};
use crate::schema_extension::SchemaExtension;
use crate::core::blueprint::telemetry::TelemetryExporter;
use crate::core::blueprint::{Blueprint, Http};
use crate::core::http::AppContext;
use crate::core::rest::{EndpointSet, Unchecked};
use crate::core::schema_extension::SchemaExtension;

pub struct ServerConfig {
pub blueprint: Blueprint,
Expand Down
12 changes: 6 additions & 6 deletions src/cli/tc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ use stripmargin::StripMargin;

use super::command::{Cli, Command};
use super::update_checker;
use crate::blueprint::Blueprint;
use crate::cli::fmt::Fmt;
use crate::cli::server::Server;
use crate::cli::{self, CLIError};
use crate::config::reader::ConfigReader;
use crate::generator::Generator;
use crate::http::API_URL_PREFIX;
use crate::print_schema;
use crate::rest::{EndpointSet, Unchecked};
use crate::core::blueprint::Blueprint;
use crate::core::config::reader::ConfigReader;
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";
Expand Down
6 changes: 3 additions & 3 deletions src/cli/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::{Layer, Registry};

use super::metrics::init_metrics;
use crate::blueprint::telemetry::{OtlpExporter, Telemetry, TelemetryExporter};
use crate::cli::CLIError;
use crate::runtime::TargetRuntime;
use crate::tracing::{default_tracing_tailcall, get_log_level, tailcall_filter_target};
use crate::core::blueprint::telemetry::{OtlpExporter, Telemetry, TelemetryExporter};
use crate::core::runtime::TargetRuntime;
use crate::core::tracing::{default_tracing_tailcall, get_log_level, tailcall_filter_target};

static RESOURCE: Lazy<Resource> = Lazy::new(|| {
Resource::default().merge(&Resource::new(vec![
Expand Down
Loading
Loading