1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
extern crate coreutils_json as json;
extern crate coreutils_jwt as jwt;
extern crate coreutils_module as module;
#[macro_use]
extern crate log;

pub mod config;

use std::sync::Arc;

pub fn new(config: config::CoreConfig) -> CoreModule {
    println!("Creating CoreModule with configuration:\n{:#?}", config);
    info!("Creating CoreModule with configuration:\n{:#?}", config);

    let jwt = jwt::new(&config.jwt);

    CoreModule {
        config: Arc::new(config),
        json: Arc::new(json::new()),
        jwt: Arc::new(jwt),
    }
}

pub struct CoreModule {
    pub config: Arc<config::CoreConfig>,
    pub json: Arc<json::JsonService>,
    pub jwt: Arc<jwt::JwtService>,
}

impl module::Module for CoreModule {
    fn init(&self) {
        info!("Core init");
    }

    fn start(&self) {
        info!("Core start")
    }
}