Skip to content

Commit

Permalink
feat: update everything to new ResourceBuilder + feature flags (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaro00 authored Jan 22, 2024
1 parent c9f7d86 commit d595ecd
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 48 deletions.
4 changes: 2 additions & 2 deletions actix-web/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ actix-web = "4.3.1"
shuttle-actix-web = "0.36.0"
shuttle-runtime = "0.36.0"
serde = "1.0.148"
shuttle-shared-db = { version = "0.36.0", features = ["postgres"] }
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] }
shuttle-shared-db = { version = "0.36.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
4 changes: 2 additions & 2 deletions axum/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ axum = "0.7.3"
serde = { version = "1.0.188", features = ["derive"] }
shuttle-axum = "0.36.0"
shuttle-runtime = "0.36.0"
shuttle-shared-db = { version = "0.36.0", features = ["postgres"] }
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] }
shuttle-shared-db = { version = "0.36.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.28.2"
32 changes: 10 additions & 22 deletions custom-resource/pdo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use async_trait::async_trait;
use serde::Serialize;
use shuttle_service::Factory;
use shuttle_service::ResourceBuilder;
use shuttle_service::Type;
use shuttle_service::{resource::Type, Error, Factory, IntoResource, ResourceBuilder};

#[derive(Serialize)]
#[derive(Default, Serialize)]
pub struct Builder {
name: String,
}

#[derive(Clone)]
pub struct Pdo {
pub name: String,
}
Expand All @@ -23,33 +20,24 @@ impl Builder {
}

#[async_trait]
impl ResourceBuilder<Pdo> for Builder {
impl ResourceBuilder for Builder {
const TYPE: Type = Type::Custom;

type Config = Self;

type Output = String;

fn new() -> Self {
Self {
name: String::new(),
}
}

fn config(&self) -> &Self::Config {
self
}

async fn output(
self,
_factory: &mut dyn Factory,
) -> Result<Self::Output, shuttle_service::Error> {
async fn output(self, _factory: &mut dyn Factory) -> Result<Self::Output, Error> {
// factory can be used to get resources from Shuttle
Ok(self.name)
}
}

async fn build(build_data: &Self::Output) -> Result<Pdo, shuttle_service::Error> {
Ok(Pdo {
name: build_data.clone(),
})
#[async_trait]
impl IntoResource<Pdo> for String {
async fn into_resource(self) -> Result<Pdo, Error> {
Ok(Pdo { name: self })
}
}
1 change: 1 addition & 0 deletions fullstack-templates/saas/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
resolver = "2"
members = ["backend"]
4 changes: 2 additions & 2 deletions fullstack-templates/saas/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ serde = { version = "1.0.160", features = ["derive"] }
shuttle-axum = "0.36.0"
shuttle-runtime = "0.36.0"
shuttle-secrets = "0.36.0"
shuttle-shared-db = { version = "0.36.0", features = ["postgres"] }
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres", "time"] }
shuttle-shared-db = { version = "0.36.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
time = { version = "0.3.20", features = ["serde"] }
tokio = "1.27.0"
tower = "0.4.13"
Expand Down
2 changes: 1 addition & 1 deletion poem/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ edition = "2021"

[dependencies]
poem = "2.0.0"
shuttle-poem = "0.37.0"
shuttle-poem = "0.36.0"
shuttle-runtime = "0.36.0"
tokio = "1.26.0"
2 changes: 1 addition & 1 deletion poem/mongodb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
mongodb = "2.4.0"
poem = "2.0.0"
shuttle-poem = "0.37.0"
shuttle-poem = "0.36.0"
shuttle-shared-db = { version = "0.36.0", features = ["mongodb"] }
shuttle-runtime = "0.36.0"
serde = { version = "1.0.148", features = ["derive"] }
Expand Down
6 changes: 3 additions & 3 deletions poem/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ edition = "2021"
[dependencies]
poem = "2.0.0"
serde = "1.0.148"
shuttle-poem = "0.37.0"
shuttle-poem = "0.36.0"
shuttle-runtime = "0.36.0"
shuttle-shared-db = { version = "0.36.0", features = ["postgres"] }
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] }
shuttle-shared-db = { version = "0.36.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
4 changes: 2 additions & 2 deletions rocket/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ edition = "2021"
[dependencies]
rocket = { version = "0.5.0", features = ["json"] }
serde = "1.0.148"
shuttle-shared-db = { version = "0.36.0", features = ["postgres"] }
shuttle-rocket = "0.36.0"
shuttle-runtime = "0.36.0"
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] }
shuttle-shared-db = { version = "0.36.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
6 changes: 3 additions & 3 deletions rocket/url-shortener/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ edition = "2021"
[dependencies]
nanoid = "0.4.0"
rocket = { version = "0.5.0", features = ["json"] }
serde = "1.0.148"
shuttle-rocket = "0.36.0"
shuttle-runtime = "0.36.0"
serde = "1.0.148"
shuttle-shared-db = { version = "0.36.0", features = ["postgres"] }
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] }
shuttle-shared-db = { version = "0.36.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
url = "2.3.1"
6 changes: 3 additions & 3 deletions serenity/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
anyhow = "1.0.66"
serde = "1.0.148"
serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
shuttle-runtime = "0.36.0"
shuttle-secrets = "0.36.0"
shuttle-serenity = "0.36.0"
shuttle-runtime = "0.36.0"
shuttle-shared-db = { version = "0.36.0", features = ["postgres"] }
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] }
shuttle-shared-db = { version = "0.36.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
tracing = "0.1.37"
4 changes: 2 additions & 2 deletions serenity/postgres/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ impl EventHandler for Bot {

let content = match command.data.name.as_str() {
"todo" => {
let command = command.data.options.get(0).expect("Expected command");
let command = command.data.options.first().expect("Expected command");

// if the todo subcommand has a CommandOption the command is either `add` or `complete`
if let Some(subcommand) = command.options.get(0) {
if let Some(subcommand) = command.options.first() {
match subcommand.resolved.as_ref().expect("Valid subcommand") {
CommandDataOptionValue::String(note) => {
db::add(&self.database, note, user_id).await.unwrap()
Expand Down
6 changes: 3 additions & 3 deletions thruster/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2021"
hyper = "0.14.23"
serde = { version = "1.0.148", features = ["derive"] }
serde_json = "1.0.89"
shuttle-aws-rds = { version = "0.36.0", features = ["postgres"] }
shuttle-thruster = "0.36.0"
shuttle-aws-rds = { version = "0.36.0", features = ["postgres", "sqlx"] }
shuttle-runtime = "0.36.0"
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] }
shuttle-thruster = "0.36.0"
sqlx = "0.7.1"
thruster = { version = "1.3.0", features = ["hyper_server"] }
tokio = "1.26.0"
4 changes: 2 additions & 2 deletions tide/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ edition = "2021"

[dependencies]
serde = { version = "1.0.148", features = ["derive"] }
shuttle-aws-rds = { version = "0.36.0", features = ["postgres"] }
shuttle-aws-rds = { version = "0.36.0", features = ["postgres", "sqlx"] }
shuttle-runtime = "0.36.0"
shuttle-tide = "0.36.0"
sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] }
sqlx = "0.7.1"
tokio = "1.26.0"
tide = "0.16.0"

0 comments on commit d595ecd

Please # to comment.