Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
ab3d1d9817
commit
21dcca47b5
1064
Cargo.lock
generated
1064
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,8 @@ tonic = "0.11.0"
|
||||
uuid = { version = "1.7.0", features = ["v7", "v4"] }
|
||||
async-trait = "0.1.77"
|
||||
mockall_double = "0.3.1"
|
||||
aws-config = { version = "1.1.5", features = ["behavior-version-latest"] }
|
||||
aws-sdk-s3 = { version = "1.15.0", features = ["behavior-version-latest"] }
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.11.0"
|
||||
|
@ -11,28 +11,21 @@ impl Deref for SharedApp {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SharedApp {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SharedApp {
|
||||
pub fn new() -> Self {
|
||||
Self(Arc::new(App::new()))
|
||||
pub fn new(app: App) -> Self {
|
||||
Self(Arc::new(app))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct App {}
|
||||
|
||||
impl Default for App {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
pub struct App {
|
||||
pub s3_client: aws_sdk_s3::Client,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
pub async fn new() -> anyhow::Result<Self> {
|
||||
let shared_config = aws_config::load_from_env().await;
|
||||
let client = aws_sdk_s3::Client::new(&shared_config);
|
||||
|
||||
Ok(Self { s3_client: client })
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
use clap::{Parser, Subcommand};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use crate::{api::axum_serve, app::SharedApp, grpc::tonic_serve};
|
||||
use crate::{
|
||||
api::axum_serve,
|
||||
app::{App, SharedApp},
|
||||
grpc::tonic_serve,
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None, subcommand_required = true)]
|
||||
@ -29,7 +33,7 @@ impl Command {
|
||||
|
||||
tracing::info!("Starting service");
|
||||
|
||||
let app = SharedApp::new();
|
||||
let app = SharedApp::new(App::new().await?);
|
||||
|
||||
tokio::select! {
|
||||
res = axum_serve(host, app.clone()) => {
|
||||
|
@ -5,15 +5,17 @@ use super::release_manager::models::ArtifactID;
|
||||
pub mod extensions;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct FileStore {}
|
||||
pub struct FileStore {
|
||||
client: aws_sdk_s3::Client,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
use mockall::{automock, mock, predicate::*};
|
||||
|
||||
#[cfg_attr(test, automock)]
|
||||
impl FileStore {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
pub fn new(client: aws_sdk_s3::Client) -> Self {
|
||||
Self { client }
|
||||
}
|
||||
|
||||
pub async fn upload_files(
|
||||
|
@ -9,6 +9,6 @@ pub trait FileStoreExt {
|
||||
|
||||
impl FileStoreExt for SharedApp {
|
||||
fn file_store(&self) -> FileStore {
|
||||
FileStore::new()
|
||||
FileStore::new(self.s3_client.clone())
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn generated_artifact_id() -> anyhow::Result<()> {
|
||||
let mut file_store = MockFileStore::new();
|
||||
let mut file_store = MockFileStore::default();
|
||||
file_store
|
||||
.expect_upload_files()
|
||||
.times(1)
|
||||
|
Loading…
Reference in New Issue
Block a user