Add managed Alpaca pool

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-08-29 16:59:34 +03:00
parent 003f47339f
commit a542225680
18 changed files with 265 additions and 183 deletions

View File

@@ -1,16 +1,15 @@
use crate::pool::AlpacaPool;
use crate::pool::{alpaca::AlpacaPool, postgres::PostgresPool};
use axum::{
routing::{delete, get, post},
Extension, Router, Server,
};
use log::info;
use sqlx::PgPool;
use std::net::SocketAddr;
pub mod assets;
pub async fn initialize_api(
database_pool: PgPool,
pub async fn run_api(
postgres_pool: PostgresPool,
alpaca_pool: AlpacaPool,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let app = Router::new()
@@ -19,7 +18,7 @@ pub async fn initialize_api(
.route("/assets", post(assets::add_asset))
.route("/assets/:symbol", post(assets::update_asset))
.route("/assets/:symbol", delete(assets::delete_asset))
.layer(Extension(database_pool))
.layer(Extension(postgres_pool))
.layer(Extension(alpaca_pool));
let addr = SocketAddr::from(([0, 0, 0, 0], 7878));