Skip to content

Commit

Permalink
fix(concurrency): can now use tally across multiple processes
Browse files Browse the repository at this point in the history
  • Loading branch information
uhryniuk committed Nov 14, 2024
1 parent 4066a4b commit 7831bce
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/database.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use sqlite::{ConnectionThreadSafe, Value};
use std::time::Duration;

#[derive(Debug)]
pub struct Counter {
Expand All @@ -16,8 +17,12 @@ pub struct Database {

impl Database {
pub fn new(name: &str) -> Result<Database> {
let mut connection = sqlite::Connection::open_thread_safe(name).expect("ORPS");
connection.set_busy_timeout(5_000_000)?;
connection.execute("PRAGMA journal_mode = WAL;")?;
let db = Database {
conn: sqlite::Connection::open_thread_safe(name)?,
conn: connection,
// conn: sqlite::Connection::open_thread_safe(name).expect("ORGIE"),
};
db.init_database()?;
db.get_default_counter()?;
Expand Down

0 comments on commit 7831bce

Please sign in to comment.