Skip to content

Commit e59b350

Browse files
shared lock among all rbac operations
1 parent d74816b commit e59b350

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/handlers/http/modal/ingest/ingestor_rbac.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
use std::collections::HashSet;
2020

2121
use actix_web::{Responder, web};
22-
use tokio::sync::Mutex;
2322

2423
use crate::{
25-
handlers::http::{modal::utils::rbac_utils::get_metadata, rbac::RBACError},
24+
handlers::http::{
25+
modal::utils::rbac_utils::get_metadata,
26+
rbac::{RBACError, UPDATE_LOCK},
27+
},
2628
rbac::{
2729
Users,
2830
map::roles,
@@ -31,9 +33,6 @@ use crate::{
3133
storage,
3234
};
3335

34-
// async aware lock for updating storage metadata and user map atomicically
35-
static UPDATE_LOCK: Mutex<()> = Mutex::const_new(());
36-
3736
// Handler for POST /api/v1/user/{username}
3837
// Creates a new user by username if it does not exists
3938
pub async fn post_user(

src/handlers/http/modal/query/querier_rbac.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use std::collections::HashSet;
2020

2121
use actix_web::{Responder, web};
22-
use tokio::sync::Mutex;
2322

2423
use crate::{
2524
handlers::http::{
@@ -28,7 +27,7 @@ use crate::{
2827
sync_user_deletion_with_ingestors, sync_users_with_roles_with_ingestors,
2928
},
3029
modal::utils::rbac_utils::{get_metadata, put_metadata},
31-
rbac::RBACError,
30+
rbac::{RBACError, UPDATE_LOCK},
3231
},
3332
rbac::{
3433
Users,
@@ -38,9 +37,6 @@ use crate::{
3837
validator,
3938
};
4039

41-
// async aware lock for updating storage metadata and user map atomically
42-
static UPDATE_LOCK: Mutex<()> = Mutex::const_new(());
43-
4440
// Handler for POST /api/v1/user/{username}
4541
// Creates a new user by username if it does not exists
4642
pub async fn post_user(

src/handlers/http/rbac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use tokio::sync::Mutex;
4343
use super::modal::utils::rbac_utils::{get_metadata, put_metadata};
4444

4545
// async aware lock for updating storage metadata and user map atomically
46-
static UPDATE_LOCK: Mutex<()> = Mutex::const_new(());
46+
pub(crate) static UPDATE_LOCK: Mutex<()> = Mutex::const_new(());
4747

4848
#[derive(serde::Serialize)]
4949
struct User {

0 commit comments

Comments
 (0)