Skip to content

Instantly share code, notes, and snippets.

@yytyd
Created October 13, 2019 12:49
Show Gist options
  • Save yytyd/506e609a99efe669768fd78f1261bfa9 to your computer and use it in GitHub Desktop.
Save yytyd/506e609a99efe669768fd78f1261bfa9 to your computer and use it in GitHub Desktop.
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