add: basic unbuildable memory data stores
This commit is contained in:
commit
431917358b
|
@ -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
BIN
docs/specifications.pdf
Normal file
Binary file not shown.
|
@ -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!");
|
||||
}
|
||||
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
17
src/libtrader/ds/server/global_state.rs
Normal file
17
src/libtrader/ds/server/global_state.rs
Normal 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>,
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
pub mod global_state;
|
||||
pub mod master_state;
|
||||
pub mod worker_state;
|
||||
pub mod worker_server;
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
pub mod ds;
|
||||
pub mod db;
|
||||
pub mod initializer;
|
||||
|
|
Loading…
Reference in New Issue
Block a user