pub fn load_from_env(cfg: &Config) -> Result<Self> {
        let mut mut_config = cfg.clone();
        if std::env::var_os(CONFIG_FILE).is_some() {
            return Config::load_from_toml(
                std::env::var_os(CONFIG_FILE).unwrap().to_str().unwrap(),
            );
        }
        env_helper!(mut_config, log_level, String, LOG_LEVEL);
        env_helper!(mut_config, log_dir, String, LOG_DIR);
        env_helper!(mut_config, num_cpus, u64, NUM_CPUS);
        env_helper!(mut_config, mysql_handler_host, String, MYSQL_HANDLER_HOST);
        env_helper!(mut_config, mysql_handler_port, u16, MYSQL_HANDLER_PORT);
        env_helper!(mut_config, max_active_sessions, u64, MAX_ACTIVE_SESSIONS);
        env_helper!(
            mut_config,
            clickhouse_handler_host,
            String,
            CLICKHOUSE_HANDLER_HOST
        );
        env_helper!(
            mut_config,
            clickhouse_handler_port,
            u16,
            CLICKHOUSE_HANDLER_PORT
        );
        env_helper!(mut_config, flight_api_address, String, FLIGHT_API_ADDRESS);
        env_helper!(mut_config, http_api_address, String, HTTP_API_ADDRESS);
        env_helper!(mut_config, metric_api_address, String, METRICS_API_ADDRESS);
        env_helper!(mut_config, store_api_address, String, STORE_API_ADDRESS);
        env_helper!(mut_config, store_api_username, User, STORE_API_USERNAME);
        env_helper!(mut_config, store_api_password, Password, STORE_API_PASSWORD);

        // for api http service
        env_helper!(mut_config, api_tls_server_cert, String, API_TLS_SERVER_CERT);

        env_helper!(mut_config, api_tls_server_key, String, API_TLS_SERVER_KEY);

        // for query rpc server
        env_helper!(mut_config, rpc_tls_server_cert, String, RPC_TLS_SERVER_CERT);

        env_helper!(mut_config, rpc_tls_server_key, String, RPC_TLS_SERVER_KEY);

        // for query rpc client
        env_helper!(
            mut_config,
            rpc_tls_query_server_root_ca_cert,
            String,
            RPC_TLS_QUERY_SERVER_ROOT_CA_CERT
        );
        env_helper!(
            mut_config,
            rpc_tls_query_service_domain_name,
            String,
            RPC_TLS_QUERY_SERVICE_DOMAIN_NAME
        );

        // for store rpc client
        env_helper!(
            mut_config,
            rpc_tls_store_server_root_ca_cert,
            String,
            RPC_TLS_STORE_SERVER_ROOT_CA_CERT
        );

        env_helper!(
            mut_config,
            rpc_tls_store_service_domain_name,
            String,
            RPC_TLS_STORE_SERVICE_DOMAIN_NAME
        );

        Ok(mut_config)
    }
/// Change config based on configured env variable
Change config based on configured env variable
Change config based on configured env variable
pub fn load_from_env(cfg: &Config) -> Result<Self> {
        let mut mut_config = cfg.clone();
        if std::env::var_os(CONFIG_FILE).is_some() {
            return Config::load_from_toml(
                std::env::var_os(CONFIG_FILE).unwrap().to_str().unwrap(),
            );
        }
        env_helper!(mut_config, log_level, String, LOG_LEVEL);
        env_helper!(mut_config, log_dir, String, LOG_DIR);
        env_helper!(mut_config, num_cpus, u64, NUM_CPUS);
        env_helper!(mut_config, mysql_handler_host, String, MYSQL_HANDLER_HOST);
        env_helper!(mut_config, mysql_handler_port, u16, MYSQL_HANDLER_PORT);
        env_helper!(mut_config, max_active_sessions, u64, MAX_ACTIVE_SESSIONS);
        env_helper!(
            mut_config,
            clickhouse_handler_host,
            String,
            CLICKHOUSE_HANDLER_HOST
        );
        env_helper!(
            mut_config,
            clickhouse_handler_port,
            u16,
            CLICKHOUSE_HANDLER_PORT
        );
        env_helper!(mut_config, flight_api_address, String, FLIGHT_API_ADDRESS);
        env_helper!(mut_config, http_api_address, String, HTTP_API_ADDRESS);
        env_helper!(mut_config, metric_api_address, String, METRICS_API_ADDRESS);
        env_helper!(mut_config, store_api_address, String, STORE_API_ADDRESS);
        env_helper!(mut_config, store_api_username, User, STORE_API_USERNAME);
        env_helper!(mut_config, store_api_password, Password, STORE_API_PASSWORD);
        // for api http service
        env_helper!(mut_config, api_tls_server_cert, String, API_TLS_SERVER_CERT);
        env_helper!(mut_config, api_tls_server_key, String, API_TLS_SERVER_KEY);
        // for query rpc server
        env_helper!(mut_config, rpc_tls_server_cert, String, RPC_TLS_SERVER_CERT);
        env_helper!(mut_config, rpc_tls_server_key, String, RPC_TLS_SERVER_KEY);
        // for query rpc client
        env_helper!(
            mut_config,
            rpc_tls_query_server_root_ca_cert,
            String,
            RPC_TLS_QUERY_SERVER_ROOT_CA_CERT
        );
        env_helper!(
            mut_config,
            rpc_tls_query_service_domain_name,
            String,
            RPC_TLS_QUERY_SERVICE_DOMAIN_NAME
        );
        // for store rpc client
        env_helper!(
            mut_config,
            rpc_tls_store_server_root_ca_cert,
            String,
            RPC_TLS_STORE_SERVER_ROOT_CA_CERT
        );
        env_helper!(
            mut_config,
            rpc_tls_store_service_domain_name,
            String,
            RPC_TLS_STORE_SERVICE_DOMAIN_NAME
        );
        Ok(mut_config)
    }
pub fn load_from_env ( cfg : & Config ) -> Result < Self > { let mut mut_config = cfg . clone ( ) ; if std :: env :: var_os ( CONFIG_FILE ) . is_some ( ) { return Config :: load_from_toml ( std :: env :: var_os ( CONFIG_FILE ) . unwrap ( ) . to_str ( ) . unwrap ( ) , ) ; } env_helper ! ( mut_config log_level String LOG_LEVEL ) ; env_helper ! ( mut_config log_dir String LOG_DIR ) ; env_helper ! ( mut_config num_cpus u64 NUM_CPUS ) ; env_helper ! ( mut_config mysql_handler_host String MYSQL_HANDLER_HOST ) ; env_helper ! ( mut_config mysql_handler_port u16 MYSQL_HANDLER_PORT ) ; env_helper ! ( mut_config max_active_sessions u64 MAX_ACTIVE_SESSIONS ) ; env_helper ! ( mut_config clickhouse_handler_host String CLICKHOUSE_HANDLER_HOST ) ; env_helper ! ( mut_config clickhouse_handler_port u16 CLICKHOUSE_HANDLER_PORT ) ; env_helper ! ( mut_config flight_api_address String FLIGHT_API_ADDRESS ) ; env_helper ! ( mut_config http_api_address String HTTP_API_ADDRESS ) ; env_helper ! ( mut_config metric_api_address String METRICS_API_ADDRESS ) ; env_helper ! ( mut_config store_api_address String STORE_API_ADDRESS ) ; env_helper ! ( mut_config store_api_username User STORE_API_USERNAME ) ; env_helper ! ( mut_config store_api_password Password STORE_API_PASSWORD ) ; // for api http service env_helper ! ( mut_config api_tls_server_cert String API_TLS_SERVER_CERT ) ; env_helper ! ( mut_config api_tls_server_key String API_TLS_SERVER_KEY ) ; // for query rpc server env_helper ! ( mut_config rpc_tls_server_cert String RPC_TLS_SERVER_CERT ) ; env_helper ! ( mut_config rpc_tls_server_key String RPC_TLS_SERVER_KEY ) ; // for query rpc client env_helper ! ( mut_config rpc_tls_query_server_root_ca_cert String RPC_TLS_QUERY_SERVER_ROOT_CA_CERT ) ; env_helper ! ( mut_config rpc_tls_query_service_domain_name String RPC_TLS_QUERY_SERVICE_DOMAIN_NAME ) ; // for store rpc client env_helper ! ( mut_config rpc_tls_store_server_root_ca_cert String RPC_TLS_STORE_SERVER_ROOT_CA_CERT ) ; env_helper ! ( mut_config rpc_tls_store_service_domain_name String RPC_TLS_STORE_SERVICE_DOMAIN_NAME ) ; Ok ( mut_config ) }
Change config based on configured env variable
Change config based on configured env variable
cfg
&Config
cfg
&Config