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

refactor: better feature scoping, fix turso compilation, prune library dependency tree #1405

Merged
merged 5 commits into from
Nov 21, 2023
Merged
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
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repository.workspace = true

[dependencies]
shuttle-common = { workspace = true, features = ["backend", "tonic"] }
shuttle-proto = { workspace = true }
shuttle-proto = { workspace = true, features = ["builder"] }

async-trait = { workspace = true }
clap = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions cargo-shuttle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ rust-version = "1.70"

[dependencies]
shuttle-common = { workspace = true, features = ["models"] }
shuttle-proto = { workspace = true }
shuttle-service = { workspace = true, features = ["builder"] }
shuttle-proto = { workspace = true, features = ["provisioner", "runtime"] }
shuttle-service = { workspace = true, features = ["builder", "runner"] }

anyhow = { workspace = true }
async-trait = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion cargo-shuttle/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use clap::{
Parser, ValueEnum,
};
use clap_complete::Shell;
use shuttle_common::{models::project::DEFAULT_IDLE_MINUTES, resource};
use shuttle_common::constants::DEFAULT_IDLE_MINUTES;
use shuttle_common::resource;
use uuid::Uuid;

#[derive(Parser)]
Expand Down
12 changes: 7 additions & 5 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use std::str::FromStr;
use shuttle_common::{
claims::{ClaimService, InjectPropagation},
constants::{
API_URL_DEFAULT, EXECUTABLE_DIRNAME, SHUTTLE_CLI_DOCS_URL, SHUTTLE_GH_ISSUE_URL,
SHUTTLE_IDLE_DOCS_URL, SHUTTLE_INSTALL_DOCS_URL, SHUTTLE_LOGIN_URL, STORAGE_DIRNAME,
API_URL_DEFAULT, DEFAULT_IDLE_MINUTES, EXECUTABLE_DIRNAME, SHUTTLE_CLI_DOCS_URL,
SHUTTLE_GH_ISSUE_URL, SHUTTLE_IDLE_DOCS_URL, SHUTTLE_INSTALL_DOCS_URL, SHUTTLE_LOGIN_URL,
STORAGE_DIRNAME,
},
deployment::{DEPLOYER_END_MESSAGES_BAD, DEPLOYER_END_MESSAGES_GOOD},
models::{
Expand All @@ -27,14 +28,15 @@ use shuttle_common::{
GIT_STRINGS_MAX_LENGTH,
},
error::ApiError,
project::{self, DEFAULT_IDLE_MINUTES},
project,
resource::get_resource_tables,
},
resource, semvers_are_compatible, ApiKey, LogItem, VersionInfo,
};
use shuttle_proto::runtime::{
self, runtime_client::RuntimeClient, LoadRequest, StartRequest, StopRequest,
runtime_client::RuntimeClient, LoadRequest, StartRequest, StopRequest,
};
use shuttle_service::runner;
use shuttle_service::{
builder::{build_workspace, BuiltService},
Environment,
Expand Down Expand Up @@ -922,7 +924,7 @@ impl Shuttle {
};

// Child process and gRPC client for sending requests to it
let (mut runtime, mut runtime_client) = runtime::start(
let (mut runtime, mut runtime_client) = runner::start(
service.is_wasm,
Environment::Local,
&format!("http://localhost:{provisioner_port}"),
Expand Down
2 changes: 1 addition & 1 deletion common-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false

[dependencies]
cargo-shuttle = { path = "../cargo-shuttle" }
shuttle-proto = { workspace = true }
shuttle-proto = { workspace = true, features = ["builder", "logger"] }

hyper = { workspace = true }
portpicker = { workspace = true }
Expand Down
16 changes: 3 additions & 13 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ backend = [
"tracing-subscriber/env-filter",
"tracing-subscriber/fmt",
"ttl_cache",
"sqlx",
"sqlx/postgres", # Fix for derive macro error when different backends enable sqlite & postgres (mainly for grouped compilation in clippy CI and Docker build)
"sqlx/sqlite",
]
claims = [
"bytes",
Expand All @@ -87,16 +84,9 @@ claims = [
]
display = ["chrono/clock", "comfy-table", "crossterm"]
openapi = ["utoipa/chrono", "utoipa/uuid"]
models = [
"async-trait",
"display",
"http",
"reqwest",
"service",
"thiserror",
]
persist = ["sqlx/sqlite", "rand"]
service = ["chrono/serde", "tracing", "tracing-subscriber", "uuid"]
models = ["async-trait", "http", "reqwest", "service", "thiserror"]
persist = ["sqlx", "rand"]
service = ["chrono/serde", "display", "tracing", "tracing-subscriber", "uuid"]
tracing = ["dep:tracing"]
wasm = [
"chrono/clock",
Expand Down
8 changes: 4 additions & 4 deletions common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ impl Default for ScopeBuilder {

#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "backend", derive(strum::Display))]
#[cfg_attr(feature = "backend", derive(sqlx::Type))]
#[cfg_attr(feature = "backend", sqlx(rename_all = "lowercase"))]
#[cfg_attr(feature = "backend", strum(serialize_all = "lowercase"))]
#[cfg_attr(feature = "display", derive(strum::Display))]
#[cfg_attr(feature = "display", strum(serialize_all = "lowercase"))]
#[cfg_attr(feature = "persist", derive(sqlx::Type))]
#[cfg_attr(feature = "persist", sqlx(rename_all = "lowercase"))]
pub enum AccountTier {
#[default]
Basic,
Expand Down
13 changes: 10 additions & 3 deletions common/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//
// Constants regarding the deployer environment and conventions
//
//! Shared constants used across Shuttle crates

/// Where executables are moved to in order to persist across deploys, relative to workspace root
pub const EXECUTABLE_DIRNAME: &str = ".shuttle-executables";
/// Where general files will persist across deploys, relative to workspace root. Used by plugins.
Expand All @@ -27,6 +26,14 @@ pub const SHUTTLE_EXAMPLES_README: &str =
pub const NEXT_NAME: &str = "shuttle-next";
pub const RUNTIME_NAME: &str = "shuttle-runtime";

/// Timeframe before a project is considered idle
pub const DEFAULT_IDLE_MINUTES: u64 = 30;

/// Function to set [DEFAULT_IDLE_MINUTES] as a serde default
pub const fn default_idle_minutes() -> u64 {
DEFAULT_IDLE_MINUTES
}

pub mod limits {
pub const MAX_PROJECTS_DEFAULT: u32 = 3;
pub const MAX_PROJECTS_EXTRA: u32 = 15;
Expand Down
1 change: 0 additions & 1 deletion common/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod admin;
pub mod deployment;
pub mod error;
#[cfg(feature = "backend")]
pub mod project;
pub mod resource;
pub mod service;
Expand Down
Loading