Created
October 13, 2019 12:49
-
-
Save yytyd/506e609a99efe669768fd78f1261bfa9 to your computer and use it in GitHub Desktop.
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
use crate::domain::repository::task::{MixInTaskRepository, TaskRepository}; | |
use crate::infra::mysql::mysqlcon::{MixInMySqlConnection, MySqlConnectionDependencies}; | |
use crate::infra::redis::pool_ctxt::{MixInRedisContext, RedisContextDependencies}; | |
use crate::infra::repository::task::TaskRepositoryDependencies; | |
pub struct Bootstrap {} | |
impl Bootstrap { | |
pub fn call(&self) { | |
let a = self.task_repository().find_task_by_id("aaa".to_string()); | |
a; | |
} | |
} | |
/// Can I resolve these boring boiler-plates by macros? | |
impl TaskRepositoryDependencies for Bootstrap {} | |
impl MySqlConnectionDependencies for Bootstrap {} | |
impl RedisContextDependencies for Bootstrap {} | |
impl MixInTaskRepository for Bootstrap { | |
type TaskRepository = Self; | |
fn task_repository(&self) -> &Self::TaskRepository { | |
&self | |
} | |
} | |
impl MixInMySqlConnection for Bootstrap { | |
type MySqlConnection = Self; | |
fn mysql_con(&self) -> &Self::MySqlConnection { | |
&self | |
} | |
} | |
impl MixInRedisContext for Bootstrap { | |
type RedisContext = Self; | |
fn redis_pool_ctxt(&self) -> &Self::RedisContext { | |
&self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment