Skip to content

Commit

Permalink
use file database instead of memory
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Oct 25, 2023
1 parent e396596 commit e6c4bed
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
.env
.users
data.db
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To work, the `katana-ci` binary must be deployed on a server with docker install
## Design

To keep things simple and flexible for CI, the `katana-ci` uses docker under the hood.
With an `in-memory` database for now, each user have an `api-key` that allows the `start` and `stop` of a Katana instance.
With an `file` database for now, each user have an `api-key` that allows the `start` and `stop` of a Katana instance.
When a user starts an instance, a new container is created and started.

The database trait `ProxifierDb` is for now targetting `Sqlite`, but may be reworked to support any backend supported by `sqlx` rust crate.
Expand Down
4 changes: 2 additions & 2 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use async_trait::async_trait;
//use regex::Regex;
use sqlx::{sqlite::SqliteConnectOptions, Error as SqlxError, FromRow, SqlitePool};

use tracing::trace;
use uuid::Uuid;
use std::str::FromStr;

/// Errors for DB operations.
#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -79,7 +79,7 @@ impl SqlxDb {
pub async fn new_any(_db_url: &str) -> Result<Self, DbError> {
Ok(Self {
pool: SqlitePool::connect_with(
SqliteConnectOptions::new().filename("file::memory:?cache=shared"),
SqliteConnectOptions::from_str("sqlite:data.db")?
)
.await?,
})
Expand Down

0 comments on commit e6c4bed

Please sign in to comment.