This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bucket | |
.put_object(&target_path, &bytes, "image/jpg") | |
.map(|_| ()) // we don't need the result since it is broken anyway | |
.map_err(|e| | |
Box::new(NetworkError::UploadPutError( | |
e.description.unwrap_or("Generic upload error".into()).into()) | |
).into() | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while let Some(msg) = msg_stream.next().await{ | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(StructOpt, Debug, Clone)] | |
#[structopt(name = "downloader")] | |
pub struct ConverterConfig{ | |
#[structopt(short = "r", long, default_value = "eu-east2", env = "S3_REGION_NAME")] | |
pub s3_region_name: String, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub async fn process(request: DownloadTask, cfg: ConverterConfig) -> Result<...>{ | |
let bytes = download_url(request.url).await?; | |
let (image, thumbnail) = tokio::task::spawn_blocking(|| process_image(bytes)).await?; | |
push_to_s3(image, cfg, request.target_path).await?; | |
push_to_s3(thumbnail, cfg, request.thumbnail_path).await?; | |
info!("Finished download for {}",request.correlation_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Generator{ | |
fn generate_UserRepository() -> Box<dyn UserRepository>; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn add_user(self, user: User){ | |
// whatever | |
self.user_repo.add(user); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct UserService { | |
user_repo: Box<dyn UserRepository> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait UserRepository{ | |
fn store(&self, user: User); | |
fn load(&self, id: u32) -> Result<User,Error>; | |
} | |
struct PostgresUserRepository; | |
struct DummyUserRepository; | |
impl UserRepository for PostgresUserRepository{ | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserService{ | |
@Autowired | |
private UserRepository userRepository; | |
public void addUser(String name){ | |
// do some business logic here | |
userRepository.addUser(name); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserService{ | |
private UserRepository userRepository; | |
public UserService(){ | |
this.userRepository = PostgresUserRepository.getInstance(); | |
} | |
public void addUser(String name){ | |
// do some business logic here | |
userRepository.addUser(name); | |
} |
NewerOlder