Replace rusoto

This commit is contained in:
Adrian Woźniak 2023-04-02 22:34:12 +02:00
parent a192a1584e
commit 23628d6f9b
11 changed files with 503 additions and 233 deletions

348
Cargo.lock generated
View File

@ -351,25 +351,6 @@ dependencies = [
"alloc-no-stdlib",
]
[[package]]
name = "amazon-actor"
version = "0.1.0"
dependencies = [
"actix",
"bitque-config",
"bytes",
"futures",
"libc",
"openssl-sys",
"rusoto_core",
"rusoto_s3",
"rusoto_signature",
"serde",
"tokio",
"tracing",
"uuid 1.3.0",
]
[[package]]
name = "android_system_properties"
version = "0.1.5"
@ -442,6 +423,22 @@ dependencies = [
"syn 2.0.12",
]
[[package]]
name = "attohttpc"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "262c3f7f5d61249d8c00e5546e2685cd15ebeeb1bc0f3cc5449350a1cb07319e"
dependencies = [
"http",
"log",
"native-tls",
"openssl",
"serde",
"serde_json",
"url",
"wildmatch",
]
[[package]]
name = "autocfg"
version = "0.1.8"
@ -457,6 +454,31 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "aws-creds"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aeeee1a5defa63cba39097a510dfe63ef53658fc8995202a610f6a8a4d03639"
dependencies = [
"attohttpc",
"dirs",
"rust-ini",
"serde",
"serde-xml-rs",
"thiserror",
"time 0.3.20",
"url",
]
[[package]]
name = "aws-region"
version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f92a8af5850d0ea0916ca3e015ab86951ded0bf4b70fd27896e81ae1dfb0af37"
dependencies = [
"thiserror",
]
[[package]]
name = "base64"
version = "0.9.3"
@ -542,9 +564,9 @@ dependencies = [
"actix",
"actix-rt",
"actix-web",
"amazon-actor",
"bitque-config",
"bitque-data",
"cloud-storage-actor",
"database-actor",
"dotenv",
"filesystem-actor",
@ -746,6 +768,24 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1"
[[package]]
name = "cloud-storage-actor"
version = "0.1.0"
dependencies = [
"actix",
"aws-creds",
"bitque-config",
"bytes",
"futures",
"libc",
"rust-s3",
"serde",
"thiserror",
"tokio",
"tracing",
"uuid 1.3.0",
]
[[package]]
name = "cloudabi"
version = "0.0.3"
@ -1029,6 +1069,9 @@ dependencies = [
[[package]]
name = "derive_db_execute"
version = "0.1.0"
dependencies = [
"diesel 2.0.3",
]
[[package]]
name = "derive_enum_iter"
@ -1174,6 +1217,7 @@ checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
dependencies = [
"block-buffer 0.10.4",
"crypto-common",
"subtle",
]
[[package]]
@ -1217,6 +1261,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "dlv-list"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257"
[[package]]
name = "dotenv"
version = "0.15.0"
@ -1585,6 +1635,9 @@ name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash 0.7.6",
]
[[package]]
name = "heck"
@ -1639,6 +1692,15 @@ dependencies = [
"digest 0.9.0",
]
[[package]]
name = "hmac"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
dependencies = [
"digest 0.10.6",
]
[[package]]
name = "hostname"
version = "0.3.1"
@ -1797,6 +1859,12 @@ dependencies = [
"windows-sys 0.45.0",
]
[[package]]
name = "ipnet"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f"
[[package]]
name = "ipnetwork"
version = "0.20.0"
@ -2013,6 +2081,17 @@ dependencies = [
"regex-automata",
]
[[package]]
name = "maybe-async"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f1b8c13cb1f814b634a96b2c725449fe7ed464a7b8781de8688be5ffbd3f305"
dependencies = [
"proc-macro2 1.0.54",
"quote 1.0.26",
"syn 1.0.109",
]
[[package]]
name = "md-5"
version = "0.9.1"
@ -2024,6 +2103,12 @@ dependencies = [
"opaque-debug",
]
[[package]]
name = "md5"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
[[package]]
name = "memchr"
version = "2.5.0"
@ -2046,6 +2131,15 @@ dependencies = [
"unicase",
]
[[package]]
name = "minidom"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9ce45d459e358790a285e7609ff5ae4cfab88b75f237e8838e62029dda397b"
dependencies = [
"rxml",
]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
@ -2246,6 +2340,16 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "ordered-multimap"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a"
dependencies = [
"dlv-list",
"hashbrown",
]
[[package]]
name = "overload"
version = "0.1.1"
@ -2666,6 +2770,45 @@ version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "reqwest"
version = "0.11.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254"
dependencies = [
"base64 0.21.0",
"bytes",
"encoding_rs",
"futures-core",
"futures-util",
"h2",
"http",
"http-body",
"hyper",
"hyper-tls",
"ipnet",
"js-sys",
"log",
"mime",
"native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
"serde",
"serde_json",
"serde_urlencoded",
"tokio",
"tokio-native-tls",
"tokio-util",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-streams",
"web-sys",
"winreg",
]
[[package]]
name = "rusoto_core"
version = "0.48.0"
@ -2734,7 +2877,7 @@ dependencies = [
"digest 0.9.0",
"futures",
"hex",
"hmac",
"hmac 0.11.0",
"http",
"hyper",
"log",
@ -2744,10 +2887,51 @@ dependencies = [
"rusoto_credential",
"rustc_version",
"serde",
"sha2",
"sha2 0.9.9",
"tokio",
]
[[package]]
name = "rust-ini"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df"
dependencies = [
"cfg-if",
"ordered-multimap",
]
[[package]]
name = "rust-s3"
version = "0.32.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6009d9d4cf910505534d62d380a0aa305805a2af0b5c3ad59a3024a0715b847"
dependencies = [
"async-trait",
"aws-creds",
"aws-region",
"base64 0.13.1",
"cfg-if",
"hex",
"hmac 0.12.1",
"http",
"log",
"maybe-async",
"md5",
"minidom",
"percent-encoding",
"reqwest",
"serde",
"serde-xml-rs",
"serde_derive",
"sha2 0.10.6",
"thiserror",
"time 0.3.20",
"tokio",
"tokio-stream",
"url",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
@ -2791,6 +2975,25 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06"
[[package]]
name = "rxml"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a071866b8c681dc2cfffa77184adc32b57b0caad4e620b6292609703bceb804"
dependencies = [
"bytes",
"pin-project-lite",
"rxml_validation",
"smartstring",
"tokio",
]
[[package]]
name = "rxml_validation"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53bc79743f9a66c2fb1f951cd83735f275d46bfe466259fbc5897bb60a0d00ee"
[[package]]
name = "ryu"
version = "1.0.13"
@ -2880,6 +3083,18 @@ dependencies = [
"serde_derive",
]
[[package]]
name = "serde-xml-rs"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65162e9059be2f6a3421ebbb4fef3e74b7d9e7c60c50a0e292c6239f19f1edfa"
dependencies = [
"log",
"serde",
"thiserror",
"xml-rs",
]
[[package]]
name = "serde_derive"
version = "1.0.159"
@ -2962,6 +3177,17 @@ dependencies = [
"opaque-debug",
]
[[package]]
name = "sha2"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.10.6",
]
[[package]]
name = "sharded-slab"
version = "0.1.4"
@ -3047,6 +3273,15 @@ version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "smartstring"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e714dff2b33f2321fdcd475b71cec79781a692d846f37f415fb395a1d2bcd48e"
dependencies = [
"static_assertions",
]
[[package]]
name = "socket2"
version = "0.4.9"
@ -3057,6 +3292,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.10.0"
@ -3338,6 +3579,17 @@ dependencies = [
"tokio",
]
[[package]]
name = "tokio-stream"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313"
dependencies = [
"futures-core",
"pin-project-lite",
"tokio",
]
[[package]]
name = "tokio-util"
version = "0.7.7"
@ -3666,6 +3918,18 @@ dependencies = [
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
dependencies = [
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.84"
@ -3695,6 +3959,19 @@ version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
[[package]]
name = "wasm-streams"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078"
dependencies = [
"futures-util",
"js-sys",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
[[package]]
name = "web-actor"
version = "0.1.0"
@ -3703,11 +3980,11 @@ dependencies = [
"actix-multipart",
"actix-web",
"actix-web-actors",
"amazon-actor",
"bincode",
"bitque-config",
"bitque-data",
"bytes",
"cloud-storage-actor",
"database-actor",
"filesystem-actor",
"futures",
@ -3722,6 +3999,16 @@ dependencies = [
"websocket-actor",
]
[[package]]
name = "web-sys"
version = "0.3.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "websocket-actor"
version = "0.1.0"
@ -3749,6 +4036,12 @@ dependencies = [
"uuid 1.3.0",
]
[[package]]
name = "wildmatch"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee583bdc5ff1cf9db20e9db5bb3ff4c3089a8f6b8b31aff265c9aba85812db86"
[[package]]
name = "winapi"
version = "0.3.9"
@ -3936,6 +4229,15 @@ dependencies = [
"memchr",
]
[[package]]
name = "winreg"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
dependencies = [
"winapi",
]
[[package]]
name = "xdg"
version = "2.4.1"

View File

@ -23,7 +23,7 @@ members = [
"./crates/web-actor",
"./crates/websocket-actor",
"./crates/mail-actor",
"./crates/amazon-actor",
"./crates/cloud-storage-actor",
"./crates/filesystem-actor",
# Client
# "./crates/web"
@ -47,5 +47,5 @@ database-actor = { path = "./crates/database-actor" }
web-actor = { path = "./crates/web-actor" }
websocket-actor = { path = "./crates/websocket-actor" }
mail-actor = { path = "./crates/mail-actor" }
amazon-actor = { path = "./crates/amazon-actor" }
cloud-storage-actor = { path = "./crates/cloud-storage-actor" }
filesystem-actor = { path = "./crates/filesystem-actor" }

View File

@ -1,86 +0,0 @@
use rusoto_s3::{PutObjectRequest, S3Client, S3};
#[derive(Debug)]
pub enum AmazonError {
UploadFailed,
}
pub struct AmazonExecutor;
impl Default for AmazonExecutor {
fn default() -> Self {
Self {}
}
}
impl actix::Actor for AmazonExecutor {
type Context = actix::SyncContext<Self>;
}
#[derive(actix::Message)]
#[rtype(result = "Result<String, AmazonError>")]
pub struct S3PutObject {
pub source: tokio::sync::broadcast::Receiver<bytes::Bytes>,
pub file_name: String,
}
impl actix::Handler<S3PutObject> for AmazonExecutor {
type Result = Result<String, AmazonError>;
fn handle(&mut self, msg: S3PutObject, _ctx: &mut Self::Context) -> Self::Result {
let S3PutObject {
// source,
mut source,
file_name,
} = msg;
bitque_config::amazon::config().set_variables();
tokio::runtime::Runtime::new()
.expect("Failed to start amazon agent")
.block_on(async {
let s3 = bitque_config::amazon::config();
tracing::debug!("{:?}", s3);
// TODO: Unable to upload as stream because there is no size_hint
// let stream = source
// .into_stream()
// .map_err(|_e| std::io::Error::from_raw_os_error(1));
// let stream = futures::StreamExt::map(stream, |b| {
// use common::bytes::Buf;
// ::bytes::Bytes::from(b.bytes())
// });
let mut v: Vec<u8> = vec![];
while let Ok(b) = source.recv().await {
v.extend_from_slice(&b)
}
let client = S3Client::new(s3.region());
let put_object = PutObjectRequest {
bucket: s3.bucket.clone(),
key: file_name.clone(),
// body: Some(rusoto_signature::ByteStream::new(stream)),
body: Some(v.into()),
..Default::default()
};
let id = match client.put_object(put_object).await {
Ok(obj) => obj,
Err(e) => {
::tracing::error!("{}", e);
return Err(AmazonError::UploadFailed);
}
};
::tracing::debug!("{:?}", id);
Ok(aws_s3_url(file_name.as_str()))
})
}
}
fn aws_s3_url(key: &str) -> String {
let config = bitque_config::amazon::config();
format!(
"https://{bucket}.s3.{region}.amazonaws.com/{key}",
bucket = config.bucket,
region = config.region_name,
key = key
)
}

View File

@ -9,7 +9,7 @@ license = "MPL-2.0"
#license-file = "../LICENSE"
[features]
aws-s3 = ["amazon-actor"]
aws-s3 = ["cloud-storage-actor"]
local-storage = ["filesystem-actor"]
default = ["local-storage"]
@ -17,7 +17,7 @@ default = ["local-storage"]
actix = { version = "0" }
actix-rt = { version = "2" }
actix-web = { version = "4" }
amazon-actor = { workspace = true, optional = true }
cloud-storage-actor = { workspace = true, optional = true }
bitque-config = { workspace = true, features = ["web", "websocket", "local-storage", "hi", "database"] }
bitque-data = { workspace = true, features = ["backend"] }
database-actor = { workspace = true }

View File

@ -1,5 +1,5 @@
[package]
name = "amazon-actor"
name = "cloud-storage-actor"
version = "0.1.0"
authors = ["Adrian Wozniak <adrian.wozniak@ita-prog.pl>"]
edition = "2018"
@ -8,21 +8,16 @@ repository = "https://gitlab.com/adrian.wozniak/bitque"
license = "MPL-2.0"
#license-file = "../LICENSE"
[lib]
name = "amazon_actor"
path = "./src/lib.rs"
[dependencies]
actix = { version = "0.13.0" }
bitque-config = { workspace = true, features = ["mail", "web", "local-storage"] }
bytes = { version = "1" }
futures = { version = "0.3.8" }
libc = { version = "0.2.0", default-features = false }
openssl-sys = { version = "*", features = ["vendored"] }
rusoto_core = { version = "0.48.0" }
rusoto_s3 = { version = "0.48.0" }
rusoto_signature = { version = "0.48.0" }
serde = { version = "*" }
tokio = { version = "1", features = ["full"] }
tracing = { version = "0.1.37" }
uuid = { version = "1.3.0", features = ["serde", "v4", "v5"] }
rust-s3 = { version = "*" }
aws-creds = { version = "=0.30.0" }
thiserror = { version = "*" }

View File

@ -0,0 +1,94 @@
use std::str::FromStr;
use awscreds::Credentials;
use s3::Region;
use tracing::warn;
#[derive(Debug, thiserror::Error)]
pub enum AmazonError {
#[error("File upload to external storage failed")]
UploadFailed,
#[error("Failed to connect to bucket")]
ConnectBucket,
#[error("Malformed external storage credentials")]
Credentials,
}
pub struct AmazonExecutor;
impl Default for AmazonExecutor {
fn default() -> Self {
Self {}
}
}
impl actix::Actor for AmazonExecutor {
type Context = actix::SyncContext<Self>;
}
#[derive(actix::Message)]
#[rtype(result = "Result<String, AmazonError>")]
pub struct S3PutObject {
pub source: tokio::sync::broadcast::Receiver<bytes::Bytes>,
pub file_name: String,
}
impl actix::Handler<S3PutObject> for AmazonExecutor {
type Result = Result<String, AmazonError>;
fn handle(&mut self, msg: S3PutObject, _ctx: &mut Self::Context) -> Self::Result {
let S3PutObject {
// source,
mut source,
file_name,
} = msg;
bitque_config::amazon::config().set_variables();
tokio::runtime::Runtime::new()
.expect("Failed to start amazon agent")
.block_on(async {
let s3 = bitque_config::amazon::config();
tracing::debug!("{:?}", s3);
let mut v: Vec<u8> = Vec::with_capacity(1024 * 1024 * 16);
while let Ok(b) = source.recv().await {
v.extend_from_slice(&b)
}
let config = bitque_config::amazon::config();
let bucket = s3::Bucket::new(
config.bucket.as_str(),
Region::from_str(config.region_name.as_str()).unwrap(),
Credentials::new(
Some(config.access_key_id.as_str()),
Some(config.secret_access_key.as_str()),
None,
None,
None,
)
.map_err(|e| {
warn!("{e}");
AmazonError::Credentials
})?,
)
.map_err(|e| {
warn!("{e}");
AmazonError::ConnectBucket
})?
.with_path_style();
let put = bucket
.put_object(file_name.as_str(), &v)
.await
.map_err(|e| {
warn!("{e}");
AmazonError::UploadFailed
})?;
if put.status_code() >= 300 {
// Error
Err(AmazonError::UploadFailed)
} else {
Ok(format!("{}/{}", bucket.url(), file_name))
}
})
}
}

View File

@ -13,4 +13,5 @@ name = "derive_db_execute"
path = "./src/lib.rs"
proc-macro = true
[dependencies]
[dev-dependencies]
diesel = { version = "2", features = ['postgres'] }

View File

@ -10,6 +10,9 @@ use proc_macro::{TokenStream, TokenTree};
use crate::parse_attr::Attributes;
#[cfg(test)]
pub mod schema;
fn parse_meta(mut it: Peekable<IntoIter>) -> (Peekable<IntoIter>, Option<Attributes>) {
let mut attrs: Option<Attributes> = None;
while let Some(token) = it.peek() {
@ -37,42 +40,42 @@ fn parse_meta(mut it: Peekable<IntoIter>) -> (Peekable<IntoIter>, Option<Attribu
///
/// ## Example:
///
/// ```no_run
/// use derive_db_execute::Execute;
/// ```
/// use derive_db_execute::Execute;
///
/// pub struct Issue {
/// pub id: i32,
/// pub name: String,
/// }
/// pub struct Issue {
/// pub id: i32,
/// pub name: String,
/// }
///
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "Issue", find = "issues.find(msg.id)")]
/// pub struct FindOne {
/// pub id: i32,
/// }
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "Issue", find = "issues.find(msg.id)")]
/// pub struct FindOne {
/// pub id: i32,
/// }
///
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "Issue", load = "issues")]
/// pub struct LoadAll;
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "Issue", load = "issues")]
/// pub struct LoadAll;
///
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "usize", destroy = "diesel::delete(issues.find(msg.id))")]
/// pub struct DeleteOne {
/// pub id: i32
/// }
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "usize", destroy = "diesel::delete(issues.find(msg.id))")]
/// pub struct DeleteOne {
/// pub id: i32
/// }
///
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "Issue", destroy = "diesel::insert_into(issues).values(name.eq(msg.name))")]
/// pub struct CreateOne {
/// pub name: String
/// }
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "Issue", destroy = "diesel::insert_into(issues).values(name.eq(msg.name))")]
/// pub struct CreateOne {
/// pub name: String
/// }
///
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "Issue", destroy = "diesel::update(issues.find(msg.id)).set(name.eq(msg.name))")]
/// pub struct UpdateOne {
/// pub id: i32,
/// pub name: String
/// }
/// #[derive(Execute)]
/// #[db_exec(schema = "issues", result = "Issue", destroy = "diesel::update(issues.find(msg.id)).set(name.eq(msg.name))")]
/// pub struct UpdateOne {
/// pub id: i32,
/// pub name: String
/// }
/// ```
#[proc_macro_derive(Execute, attributes(db_exec))]
pub fn derive_enum_iter(item: TokenStream) -> TokenStream {

View File

@ -0,0 +1,9 @@
use diesel::prelude::*;
table! {
use diesel::sql_types::*;
issues (id) {
id -> Int4,
title -> Text,
}
}

View File

@ -14,7 +14,7 @@ path = "./src/lib.rs"
[features]
local-storage = ["filesystem-actor"]
aws-s3 = ["amazon-actor"]
aws-s3 = ["cloud-storage-actor"]
default = ["local-storage"]
[dependencies]
@ -22,7 +22,7 @@ actix = { version = "0.13.0" }
actix-multipart = { version = "*" }
actix-web = { version = "4" }
actix-web-actors = { version = "4" }
amazon-actor = { workspace = true, optional = true }
cloud-storage-actor = { workspace = true, optional = true }
bincode = { version = "*" }
bitque-config = { workspace = true, features = ["mail", "web", "local-storage"] }
bitque-data = { workspace = true, features = ["backend"] }

View File

@ -1,78 +1,30 @@
version: '3.2'
services:
db:
image: postgres:latest
environment:
- POSTGRES_USER=postgres
- POSTGRES_HOST_AUTH_METHOD=trust
build-server:
build:
dockerfile: ./Dockerfile.build
context: .
stdin_open: true
tty: true
volumes:
- ./build:/app/build
- type: volume
source: rs-target
target: /app/bitque-server/target
- ./Cargo.toml:/app/Cargo.toml
- ./Cargo.lock:/app/Cargo.lock
- ./bitque-server:/app/bitque-server
- ./bitque-data:/app/bitque-data
- ./bitque-cli:/app/bitque-cli
- ./bitque-client:/app/bitque-client
server:
build:
dockerfile: ./bitque-server/Dockerfile
context: .
depends_on:
- db
environment:
- DATABASE_URL=postgres://postgres@db/bitque
- JIRS_SERVER_PORT=5000
- JIRS_SERVER_BIND=0.0.0.0
- RUST_LOG=debug
- DEBUG=true
- JIRS_CLIENT_PORT=7000
- JIRS_CLIENT_BIND=0.0.0.0
nginx:
image: nginx:latest
depends_on:
- client
- server
ports:
- 80:80
volumes:
- ./.builds/nginx.conf:/etc/nginx/conf.d/default.conf
- type: volume
source: assets
target: /assets
volume:
nocopy: true
client:
build:
dockerfile: ./bitque-client/Dockerfile
context: .
env_file:
- .env
environment:
- JIRS_SERVER_PORT=80
- JIRS_SERVER_BIND=bitque.lvh.me
- JIRS_CLIENT_PORT=80
- JIRS_CLIENT_BIND=bitque.lvh.me
volumes:
- type: volume
source: assets
target: /assets
volume:
nocopy: true
volumes:
assets:
build:
rs-target:
version: '3.0'
services:
app:
build:
dockerfile: Dockerfile.build
minio:
image: docker.io/bitnami/minio:2023
ports:
- '9000:9000'
- '9001:9001'
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=miniosecret
command:
- minio
- server
- /data
- --console-address
- ":9001"
minio-client:
build:
context: .
dockerfile: ./docker/mc.Dockerfile
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=miniosecret
- MINIO_DEFAULT_BUCKETS=conf
depends_on:
- minio