Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 323dd43c5b | |||
| 4629a02398 | |||
| 13ea0619cd | |||
| e9427b769e | |||
| ecb8d874c2 | |||
| 287f095294 | |||
| 9570293588 | |||
| 4582987aba | |||
| 8384b56f1f | |||
| c8d254e6c4 |
@ -1,8 +1,6 @@
|
|||||||
[registries.lugit]
|
[registries.lugit]
|
||||||
index = "sparse+http://lugit.local/api/packages/lucodear/cargo/"
|
index = "sparse+https://git.lucode.dev/api/packages/lucas/cargo/"
|
||||||
|
|
||||||
[registries.lugit-sa]
|
|
||||||
index = "sparse+http://lugit.local/api/packages/singleaction/cargo/"
|
|
||||||
|
|
||||||
[registry]
|
[registry]
|
||||||
global-credential-providers = ["cargo:token"]
|
global-credential-providers = ["cargo:token"]
|
||||||
|
|||||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -19,7 +19,7 @@
|
|||||||
"target": true,
|
"target": true,
|
||||||
|
|
||||||
// 📝 readmes
|
// 📝 readmes
|
||||||
"**/**/README.md": true,
|
// "**/**/README.md": true,
|
||||||
|
|
||||||
// 🗑️
|
// 🗑️
|
||||||
"check_size.py": true,
|
"check_size.py": true,
|
||||||
|
|||||||
1870
Cargo.lock
generated
1870
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
38
Cargo.toml
38
Cargo.toml
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rustler-core"
|
name = "rustler-core"
|
||||||
version = "0.3.9"
|
version = "0.4.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "🐎 » rustler-core market data extractor core functionality"
|
description = "🐎 » rustler-core market data extractor core functionality"
|
||||||
authors = ["Lucas Colombo <lucas@lucode.ar>"]
|
authors = ["Lucas Colombo <lucas@lucode.ar>"]
|
||||||
@ -15,44 +15,44 @@ path = "lib/lib.rs"
|
|||||||
# utils
|
# utils
|
||||||
eyre = { version = "0.6.12", default-features = false }
|
eyre = { version = "0.6.12", default-features = false }
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
chrono = "0.4.38"
|
chrono = "0.4.40"
|
||||||
getset = "0.1.2"
|
getset = "0.1.5"
|
||||||
|
|
||||||
# async
|
# async
|
||||||
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.44.1", features = ["macros", "rt-multi-thread"] }
|
||||||
async-trait = "0.1.80"
|
async-trait = "0.1.88"
|
||||||
|
|
||||||
# grpc & websocket
|
# grpc & websocket
|
||||||
tokio-tungstenite = { version = "0.22.0" }
|
tokio-tungstenite = { version = "0.26.2" }
|
||||||
tonic = "0.11.0"
|
tonic = "0.13.0"
|
||||||
prost = "0.12.6" # protocol buffers
|
prost = "0.13.5" # protocol buffers
|
||||||
futures = "0.3.30"
|
futures = "0.3.31"
|
||||||
tokio-util = "0.7.11"
|
tokio-util = "0.7.14"
|
||||||
|
|
||||||
# database
|
# database
|
||||||
sea-orm = { version = "0.12.15", features = [
|
sea-orm = { version = "1.1.7", features = [
|
||||||
"runtime-tokio-native-tls",
|
"runtime-tokio-native-tls",
|
||||||
"sqlx-sqlite",
|
"sqlx-sqlite",
|
||||||
"macros",
|
"macros",
|
||||||
] }
|
] }
|
||||||
sea-orm-migration = { version = "0.12.15", features = [
|
sea-orm-migration = { version = "1.1.7", features = [
|
||||||
"runtime-tokio-native-tls",
|
"runtime-tokio-native-tls",
|
||||||
"sqlx-sqlite",
|
"sqlx-sqlite",
|
||||||
] }
|
] }
|
||||||
redis = { version = "0.25.4", features = ["tokio-comp"] }
|
redis = { version = "0.29.2", features = ["tokio-comp"] }
|
||||||
|
|
||||||
# other
|
# other
|
||||||
serde = { version = "1.0.203", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = "1.0.117"
|
serde_json = "1.0.140"
|
||||||
uuid = { version = "1.8.0", features = ["v4", "fast-rng"] }
|
uuid = { version = "1.16.0", features = ["v4", "fast-rng"] }
|
||||||
lool = { version = "^0.3.2", registry = "lugit", features = [
|
lool = { version = "^0.9.0", registry = "lugit", features = [
|
||||||
"cli.stylize",
|
"cli.stylize",
|
||||||
"logger",
|
"logger",
|
||||||
"sched.tokio",
|
"sched.tokio",
|
||||||
"sched.rule-recurrence",
|
"sched.rule-recurrence",
|
||||||
"macros",
|
"macros",
|
||||||
] }
|
] }
|
||||||
async-stream = "0.3.5"
|
async-stream = "0.3.6"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tonic-build = "0.11.0"
|
tonic-build = "0.13.0"
|
||||||
|
|||||||
@ -14,7 +14,7 @@ fn main() {
|
|||||||
fn compile_proto(proto_file: &str) {
|
fn compile_proto(proto_file: &str) {
|
||||||
tonic_build::configure()
|
tonic_build::configure()
|
||||||
.build_server(true)
|
.build_server(true)
|
||||||
.compile(&[proto_file], &["."])
|
.compile_protos(&[proto_file], &["."])
|
||||||
.unwrap_or_else(|e| panic!("protobuf compile error: {}", e));
|
.unwrap_or_else(|e| panic!("protobuf compile error: {}", e));
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed={}", proto_file);
|
println!("cargo:rerun-if-changed={}", proto_file);
|
||||||
|
|||||||
@ -50,10 +50,10 @@ impl<RM: BusMessage> PublisherTrait<RM> for RedisPublisher<RM> {
|
|||||||
async fn publish(&mut self, value: RM) -> Result<()> {
|
async fn publish(&mut self, value: RM) -> Result<()> {
|
||||||
let obj_key = key(self.get_prefix(), value.to_bus_key());
|
let obj_key = key(self.get_prefix(), value.to_bus_key());
|
||||||
// set hash key
|
// set hash key
|
||||||
self.conn.hset_multiple(&obj_key, value.to_bus_val().as_slice()).await?;
|
() = self.conn.hset_multiple(&obj_key, value.to_bus_val().as_slice()).await?;
|
||||||
|
|
||||||
// publish to the appropriate channel
|
// publish to the appropriate channel
|
||||||
self.conn.publish(&obj_key, value.as_message()).await?;
|
() = self.conn.publish(&obj_key, value.as_message()).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ impl MigrationTrait for Migration {
|
|||||||
.col(ColumnDef::new(Ticker::Symbol).string().not_null())
|
.col(ColumnDef::new(Ticker::Symbol).string().not_null())
|
||||||
.col(ColumnDef::new(Ticker::QuoteSymbol).string().null())
|
.col(ColumnDef::new(Ticker::QuoteSymbol).string().null())
|
||||||
.col(ColumnDef::new(Ticker::MarketId).string().not_null())
|
.col(ColumnDef::new(Ticker::MarketId).string().not_null())
|
||||||
|
.col(ColumnDef::new(Ticker::Active).boolean().not_null().default(true))
|
||||||
.foreign_key(
|
.foreign_key(
|
||||||
ForeignKey::create()
|
ForeignKey::create()
|
||||||
.name("fk_ticker_market_id")
|
.name("fk_ticker_market_id")
|
||||||
@ -51,4 +52,6 @@ enum Ticker {
|
|||||||
QuoteSymbol,
|
QuoteSymbol,
|
||||||
/// Market ID
|
/// Market ID
|
||||||
MarketId,
|
MarketId,
|
||||||
|
/// Active status of the ticker. This defines if quotes are generated for this ticker or not.
|
||||||
|
Active,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,21 +35,20 @@ pub mod db {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const RUSTLER_DATABASE: &str = "RUSTLER_DATABASE";
|
const DATABASE_URL: &str = "DATABASE_URL";
|
||||||
|
|
||||||
fn get_default_conn_str() -> String {
|
fn get_default_conn_str() -> String {
|
||||||
let conn_str = s!("sqlite://rustler.db?mode=rwc");
|
let conn_str = s!("sqlite://rustler.db?mode=rwc");
|
||||||
info!(
|
info!(
|
||||||
"No `{}` env var found, using default: {}",
|
"No `{}` env var found, using default: {}",
|
||||||
RUSTLER_DATABASE.italic(),
|
DATABASE_URL.italic(),
|
||||||
conn_str.green()
|
conn_str.green()
|
||||||
);
|
);
|
||||||
conn_str
|
conn_str
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_connection() -> Result<DatabaseConnection> {
|
pub async fn get_connection() -> Result<DatabaseConnection> {
|
||||||
let db_conn_str =
|
let db_conn_str = std::env::var(DATABASE_URL).unwrap_or_else(|_| get_default_conn_str());
|
||||||
std::env::var(RUSTLER_DATABASE).unwrap_or_else(|_| get_default_conn_str());
|
|
||||||
|
|
||||||
let mut conn_opts = ConnectOptions::new(db_conn_str.to_owned());
|
let mut conn_opts = ConnectOptions::new(db_conn_str.to_owned());
|
||||||
conn_opts.sqlx_logging(false);
|
conn_opts.sqlx_logging(false);
|
||||||
|
|||||||
@ -11,6 +11,7 @@ pub struct Model {
|
|||||||
pub symbol: String,
|
pub symbol: String,
|
||||||
pub quote_symbol: Option<String>,
|
pub quote_symbol: Option<String>,
|
||||||
pub market_id: String,
|
pub market_id: String,
|
||||||
|
pub active: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
|||||||
@ -24,6 +24,13 @@ impl Service {
|
|||||||
Ok(tickers)
|
Ok(tickers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 🐎 » get all active
|
||||||
|
pub async fn get_all_active(&self) -> Result<Vec<TickerModel>, DbErr> {
|
||||||
|
let tickers =
|
||||||
|
Ticker::find().filter(ticker::Column::Active.eq(true)).all(&self.conn).await?;
|
||||||
|
Ok(tickers)
|
||||||
|
}
|
||||||
|
|
||||||
/// 🐎 » retrieves a ticker from the database, given its id
|
/// 🐎 » retrieves a ticker from the database, given its id
|
||||||
pub async fn get(&self, id: String) -> Result<Option<TickerModel>, DbErr> {
|
pub async fn get(&self, id: String) -> Result<Option<TickerModel>, DbErr> {
|
||||||
let ticker = Ticker::find_by_id(id).one(&self.conn).await?;
|
let ticker = Ticker::find_by_id(id).one(&self.conn).await?;
|
||||||
|
|||||||
@ -23,6 +23,7 @@ message Ticker {
|
|||||||
string symbol = 2;
|
string symbol = 2;
|
||||||
optional string quote_symbol = 3;
|
optional string quote_symbol = 3;
|
||||||
string market_id = 4;
|
string market_id = 4;
|
||||||
|
bool active = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Tickers {
|
message Tickers {
|
||||||
|
|||||||
@ -22,6 +22,7 @@ impl Ticker {
|
|||||||
symbol: self.symbol,
|
symbol: self.symbol,
|
||||||
quote_symbol: self.quote_symbol,
|
quote_symbol: self.quote_symbol,
|
||||||
market_id: self.market_id,
|
market_id: self.market_id,
|
||||||
|
active: self.active,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ impl Ticker {
|
|||||||
symbol: model.symbol,
|
symbol: model.symbol,
|
||||||
quote_symbol: model.quote_symbol,
|
quote_symbol: model.quote_symbol,
|
||||||
market_id: model.market_id,
|
market_id: model.market_id,
|
||||||
|
active: model.active,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
allow-branch = ["master"]
|
allow-branch = ["master"]
|
||||||
sign-commit = true
|
sign-commit = true
|
||||||
sign-tag = true
|
sign-tag = true
|
||||||
registry = "lugit-sa"
|
registry = "lugit"
|
||||||
pre-release-commit-message = "release: 🔖 v{{version}}"
|
pre-release-commit-message = "release: 🔖 v{{version}}"
|
||||||
tag-message = "release: 🔖 v{{version}}"
|
tag-message = "release: 🔖 v{{version}}"
|
||||||
tag-prefix = ""
|
tag-prefix = ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user