add: basic unbuildable memory data stores

This commit is contained in:
realaltffour 2020-07-24 10:38:17 +03:00
commit 431917358b
No known key found for this signature in database
GPG Key ID: C1265D839D44DCB1
7 changed files with 31 additions and 29 deletions

View File

@ -16,6 +16,9 @@ path = "src/bin/sandbox/sandbox.rs"
test = false
bench = false
[features]
master_server = []
[dependencies]
chrono = "0.4"
postgres = "0.17.3"

BIN
docs/specifications.pdf Normal file

Binary file not shown.

View File

@ -1,28 +1,11 @@
use libtrader::ds::account::account::Account;
use libtrader::ds::account::portfolio::Portfolio;
use postgres::{Client, NoTls};
use libtrader::initializer::libtrader_init;
fn main() {
let account = Account{
username: "test".to_string(),
email: "email".to_string(),
is_pass: true,
pass_hash: "passhash".to_string(),
portfolio: Portfolio{
position_history: Vec::new(),
open_positions: Vec::new()
},
transactions: Vec::new()
};
let mut client = Client::connect("host=localhost port=5432 user=pt_usr password=test dbname=pt_db", NoTls).unwrap();
client.batch_execute("
CREATE TABLE accounts (
id SERIAL PRIMARY KEY,
acct CHAR
)").unwrap();
match libtrader_init() {
Ok(()) => println!("connected successfully"),
Err(err) => println!("Failed with error: {}", err),
}
println!("Hello World!");
}

View File

@ -1,9 +1,6 @@
use crate::db::config::{*};
use postgres::{Client, NoTls};
pub fn init() -> Result<Client, postgres::error::Error> {
let client = Client::connect(format!("host={} port={} user={} db={} password={}", DB_HOST, DB_HOST_PORT, DB_USER, DB_NAME, DB_PASS).as_str(), NoTls);
return client;
pub fn db_init() -> Result<(), String> {
// todo: load data
Ok(())
}

View File

@ -0,0 +1,17 @@
use std::collections::HashMap;
#[allow(unused_imports)]
use crate::ds::server::master_state::MasterState;
#[allow(unused_imports)]
use crate::ds::server::worker_state::WorkerState;
#[derive(Default, PartialEq, Debug)]
pub struct GlobalState {
#[cfg(feature="master_server")]
pub state: MasterState,
#[cfg(feature="worker_server")]
pub state: WorkerState,
pub companies: HashMap<String, Companies>,
pub stock_vals: HashMap<String, StockVal>,
}

View File

@ -1,3 +1,4 @@
pub mod global_state;
pub mod master_state;
pub mod worker_state;
pub mod worker_server;

View File

@ -1,2 +1,3 @@
pub mod ds;
pub mod db;
pub mod initializer;