Skip to content

Commit

Permalink
fix(consumer): Db connection pool timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jan 21, 2025
1 parent d6cfc78 commit 7c54f3d
Show file tree
Hide file tree
Showing 22 changed files with 432 additions and 345 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/fuel-streams-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }

[dev-dependencies]
pretty_assertions = { workspace = true }
Expand Down
14 changes: 4 additions & 10 deletions crates/fuel-streams-domains/src/inputs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,10 @@ pub enum InputType {

impl std::fmt::Display for InputType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.to_string())
}
}

impl From<InputType> for String {
fn from(value: InputType) -> Self {
match value {
InputType::Contract => "contract".to_string(),
InputType::Coin => "coin".to_string(),
InputType::Message => "message".to_string(),
match self {
InputType::Contract => write!(f, "contract"),
InputType::Coin => write!(f, "coin"),
InputType::Message => write!(f, "message"),
}
}
}
Expand Down
18 changes: 6 additions & 12 deletions crates/fuel-streams-domains/src/outputs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,12 @@ pub enum OutputType {

impl std::fmt::Display for OutputType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.to_string())
}
}

impl From<OutputType> for String {
fn from(value: OutputType) -> Self {
match value {
OutputType::Coin => "coin".to_string(),
OutputType::Contract => "contract".to_string(),
OutputType::Change => "change".to_string(),
OutputType::Variable => "variable".to_string(),
OutputType::ContractCreated => "contract_created".to_string(),
match self {
OutputType::Coin => write!(f, "coin"),
OutputType::Contract => write!(f, "contract"),
OutputType::Change => write!(f, "change"),
OutputType::Variable => write!(f, "variable"),
OutputType::ContractCreated => write!(f, "contract_created"),
}
}
}
Expand Down
16 changes: 15 additions & 1 deletion crates/fuel-streams-domains/src/receipts/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,21 @@ pub enum ReceiptType {

impl std::fmt::Display for ReceiptType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.to_string())
match self {
ReceiptType::Call => write!(f, "call"),
ReceiptType::Return => write!(f, "return"),
ReceiptType::ReturnData => write!(f, "return_data"),
ReceiptType::Panic => write!(f, "panic"),
ReceiptType::Revert => write!(f, "revert"),
ReceiptType::Log => write!(f, "log"),
ReceiptType::LogData => write!(f, "log_data"),
ReceiptType::Transfer => write!(f, "transfer"),
ReceiptType::TransferOut => write!(f, "transfer_out"),
ReceiptType::ScriptResult => write!(f, "script_result"),
ReceiptType::MessageOut => write!(f, "message_out"),
ReceiptType::Mint => write!(f, "mint"),
ReceiptType::Burn => write!(f, "burn"),
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/fuel-streams-store/src/db/db_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Db {
.min_connections(opts.min_connections.unwrap_or_default())
.acquire_timeout(opts.acquire_timeout.unwrap_or_default())
.idle_timeout(opts.idle_timeout)
.test_before_acquire(true)
.test_before_acquire(false)
.connect_with(connections_opts)
.await
.map_err(DbError::Open)
Expand Down
2 changes: 1 addition & 1 deletion crates/fuel-streams-store/src/store/store_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub async fn find_last_block_height(
db: &Db,
options: QueryOptions,
) -> StoreResult<u64> {
let select = format!("SELECT block_height FROM blocks");
let select = "SELECT block_height FROM blocks".to_string();
let mut query_builder = sqlx::QueryBuilder::new(select);
if let Some(ns) = options.namespace {
query_builder
Expand Down
238 changes: 0 additions & 238 deletions crates/sv-consumer/src/block_process.rs

This file was deleted.

2 changes: 2 additions & 0 deletions crates/sv-consumer/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ pub enum ConsumerError {
MessageBrokerClient(#[from] fuel_message_broker::MessageBrokerError),
#[error(transparent)]
Sqlx(#[from] sqlx::Error),
#[error("Database operation timed out")]
DatabaseTimeout,
}
Loading

0 comments on commit 7c54f3d

Please sign in to comment.