Skip to content

Commit

Permalink
chore: with further debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
gk-kindred committed May 29, 2024
1 parent df45d9c commit 789ab11
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 342 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ coverage
.env
#### node ####
node_modules
*.node
# *.node
.yarn/
dist/

Expand Down
2 changes: 1 addition & 1 deletion scylla_operations/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl ScyllaOperations {
}
}
#[async_trait]
pub trait Persistence
pub trait Persistence: std::fmt::Debug
where
Self::PersistenceError: From<ScyllaOperationsError>,
{
Expand Down
585 changes: 248 additions & 337 deletions scylla_pg_client/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions scylla_pg_client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"email": "[email protected]",
"license": "MIT",
"dependencies": {
"scylla_pg_js": "0.1.24"
"scylla_pg_js": "file:../scylla_pg_js"
},
"devDependencies": {
"@ava/typescript": "^4.1.0",
Expand All @@ -37,4 +37,4 @@
"build": "tsc",
"test": "ava"
}
}
}
Binary file added scylla_pg_js/scylla_pg_js.darwin-arm64.node
Binary file not shown.
5 changes: 4 additions & 1 deletion scylla_pg_js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl ScyllaManager {
/// Convert rust error into `napi::Error`
#[napi]
pub fn init_pg_config(js_db_config: JsDbConfig) -> napi::Result<ScyllaManager> {
println!(" Inside init_pg_config......");
let port = validate_port(js_db_config.pg_port)?;
let pg_pool_size = validate_pool_size(js_db_config.pg_pool_size)?;
let pg_config = PGConfig {
Expand All @@ -50,8 +51,10 @@ impl ScyllaManager {
pg_database: js_db_config.pg_database,
pg_pool_size,
};
let pg_manager = PgManager::from_config(&pg_config);
println!("pg_manager....\n\n {pg_manager:?}",);
Ok(Self {
pg_manager: PgManager::from_config(&pg_config).map_err(map_error_to_napi_error)?,
pg_manager: pg_manager.map_err(map_error_to_napi_error)?,
})
}
/// # Errors
Expand Down
1 change: 1 addition & 0 deletions scylla_pg_lib/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const DELETE_BATCH_TASK_SQL: &str = "
DELETE from task where data ->> 'status' in ('completed', 'cancelled', 'aborted') AND data ->> 'updated' < $1
";

#[derive(Debug)]
pub struct PgAdapter {
pub pool: Pool,
}
Expand Down
4 changes: 4 additions & 0 deletions scylla_pg_lib/src/manager.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
//! PG Manager used by external crates to deal with Database operations. `PGAdapter` is not accessible without `PGManager`
use std::fmt::Debug;

use crate::adapter::PgAdapter;
use crate::error::PgAdapterError;
use scylla_models::{AddTaskModel, GetTaskModel, Task, TaskError, TaskStatus, UpdateOperation, UpdateTaskModel};
use scylla_operations::task::{Persistence, ScyllaOperations};
use scylla_pg_core::config::PGConfig;
use scylla_pg_core::connection::get_pool;

#[derive(Debug)]
pub struct PgManager {
pg_adapter: Box<dyn Persistence<PersistenceError = PgAdapterError> + Send + Sync>,
}
Expand Down
1 change: 1 addition & 0 deletions scylla_pg_lib/src/manager/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use super::PgManager;
use async_trait::async_trait;
use scylla_models::*;

#[derive(Debug)]
struct MockPgAdapter {
insert: fn(Task) -> Result<Task, PgAdapterError>,
update: fn(Task) -> Result<Task, PgAdapterError>,
Expand Down

0 comments on commit 789ab11

Please sign in to comment.