-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into triton-build
- Loading branch information
Showing
169 changed files
with
6,602 additions
and
1,363 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "das-core" | ||
version.workspace = true | ||
edition.workspace = true | ||
repository.workspace = true | ||
publish.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = { workspace = true } | ||
anyhow = { workspace = true } | ||
sqlx = { workspace = true } | ||
cadence = { workspace = true } | ||
cadence-macros = { workspace = true } | ||
|
||
[lints] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use anyhow::Result; | ||
use clap::Parser; | ||
use sqlx::{ | ||
postgres::{PgConnectOptions, PgPoolOptions}, | ||
PgPool, | ||
}; | ||
|
||
#[derive(Debug, Parser, Clone)] | ||
pub struct PoolArgs { | ||
/// The database URL. | ||
#[arg(long, env)] | ||
pub database_url: String, | ||
/// The maximum number of connections to the database. | ||
#[arg(long, env, default_value = "125")] | ||
pub database_max_connections: u32, | ||
/// The minimum number of connections to the database. | ||
#[arg(long, env, default_value = "5")] | ||
pub database_min_connections: u32, | ||
} | ||
|
||
///// Establishes a connection to the database using the provided configuration. | ||
///// | ||
///// # Arguments | ||
///// | ||
///// * `config` - A `PoolArgs` struct containing the database URL and the minimum and maximum number of connections. | ||
///// | ||
///// # Returns | ||
///// | ||
///// * `Result<DatabaseConnection, DbErr>` - On success, returns a `DatabaseConnection`. On failure, returns a `DbErr`. | ||
pub async fn connect_db(config: PoolArgs) -> Result<PgPool, sqlx::Error> { | ||
let options: PgConnectOptions = config.database_url.parse()?; | ||
|
||
PgPoolOptions::new() | ||
.min_connections(config.database_min_connections) | ||
.max_connections(config.database_max_connections) | ||
.connect_with(options) | ||
.await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod db; | ||
mod metrics; | ||
|
||
pub use db::*; | ||
pub use metrics::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use anyhow::Result; | ||
use cadence::{BufferedUdpMetricSink, QueuingMetricSink, StatsdClient}; | ||
use cadence_macros::set_global_default; | ||
use clap::Parser; | ||
use std::net::UdpSocket; | ||
|
||
#[derive(Clone, Parser, Debug)] | ||
pub struct MetricsArgs { | ||
#[arg(long, env, default_value = "127.0.0.1")] | ||
pub metrics_host: String, | ||
#[arg(long, env, default_value = "8125")] | ||
pub metrics_port: u16, | ||
#[arg(long, env, default_value = "das.backfiller")] | ||
pub metrics_prefix: String, | ||
} | ||
|
||
pub fn setup_metrics(config: MetricsArgs) -> Result<()> { | ||
let host = (config.metrics_host, config.metrics_port); | ||
|
||
let socket = UdpSocket::bind("0.0.0.0:0")?; | ||
socket.set_nonblocking(true)?; | ||
|
||
let udp_sink = BufferedUdpMetricSink::from(host, socket)?; | ||
let queuing_sink = QueuingMetricSink::from(udp_sink); | ||
|
||
let client = StatsdClient::from_sink(&config.metrics_prefix, queuing_sink); | ||
|
||
set_global_default(client); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod api; | ||
|
||
pub mod builder; | ||
pub mod config; | ||
pub mod error; | ||
pub mod validation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use crate::DasApiError; | ||
use crate::error::DasApiError; | ||
use solana_sdk::pubkey::Pubkey; | ||
use std::str::FromStr; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.