mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 05:19:21 +00:00
Simplify configuration management
This commit is contained in:
parent
9ff14a1fcf
commit
ffc6778822
@ -35,7 +35,7 @@ pub struct IndependentPushService {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
pub port: i32,
|
||||
pub port: u64,
|
||||
pub listen_address: String,
|
||||
pub storage_url: String,
|
||||
pub storage_path: String,
|
||||
@ -59,10 +59,6 @@ pub struct Config {
|
||||
static mut CONF: Option<Config> = None;
|
||||
|
||||
impl Config {
|
||||
fn yaml_i32(parsed: &Yaml, name: &str) -> i32 {
|
||||
parsed[name].as_i64().expect(format!("{} is missing (int)", name).as_str()) as i32
|
||||
}
|
||||
|
||||
fn yaml_u64(parsed: &Yaml, name: &str) -> u64 {
|
||||
parsed[name].as_i64().expect(format!("{} is missing (int)", name).as_str()) as u64
|
||||
}
|
||||
@ -123,7 +119,7 @@ impl Config {
|
||||
};
|
||||
|
||||
let conf = Config {
|
||||
port: Config::yaml_i32(parsed, "server-port") as i32,
|
||||
port: Config::yaml_u64(parsed, "server-port"),
|
||||
listen_address: Config::yaml_str(parsed, "server-address"),
|
||||
|
||||
storage_url: Config::yaml_str(parsed, "storage-url"),
|
||||
|
@ -599,8 +599,8 @@ pub fn query<E, F: Fn(&RowResult) -> ProcessRowResult<E>>(info: QueryInfo, proce
|
||||
|
||||
/// Count the number of results a query would have produced
|
||||
pub fn count(mut q: QueryInfo) -> ResultBoxError<usize> {
|
||||
&q.fields.clear();
|
||||
&q.fields.push("COUNT(*) as count".to_string());
|
||||
q.fields.clear();
|
||||
q.fields.push("COUNT(*) as count".to_string());
|
||||
|
||||
query(q, |res| res.get_usize("count"))?.pop()
|
||||
.ok_or(ExecError::boxed_new("database::count did not return a result!"))
|
||||
|
Loading…
Reference in New Issue
Block a user