Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pgdog-stats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ pub mod resharding;
pub mod schema;
pub mod server;
pub mod state;
pub mod user;

pub use memory::*;
pub use pool::*;
pub use replication::*;
pub use resharding::*;
pub use schema::*;
pub use user::*;
11 changes: 1 addition & 10 deletions pgdog-stats/src/resharding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{sync::Arc, time::SystemTime};
use pgdog_config::ServerAuth;
use serde::{Deserialize, Serialize};

use crate::Lsn;
use crate::{Lsn, User};

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct TableCopy {
Expand Down Expand Up @@ -121,12 +121,3 @@ impl std::fmt::Display for SyncState {
}
}
}

/// Database/user pair that identifies a database cluster pool.
#[derive(Debug, PartialEq, Hash, Eq, Clone, Default, Serialize, Deserialize)]
pub struct User {
/// User name.
pub user: String,
/// Database name.
pub database: String,
}
16 changes: 16 additions & 0 deletions pgdog-stats/src/user.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use serde::{Deserialize, Serialize};

/// Database/user pair that identifies a database cluster pool.
#[derive(Debug, PartialEq, Hash, Eq, Clone, Default, Serialize, Deserialize)]
pub struct User {
/// User name.
pub user: String,
/// Database name.
pub database: String,
}

impl std::fmt::Display for User {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}/{}", self.user, self.database)
}
}
24 changes: 1 addition & 23 deletions pgdog/src/backend/databases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,29 +265,7 @@ pub async fn cutover(source: &str, destination: &str) -> Result<(), Error> {
Ok(())
}

/// Database/user pair that identifies a database cluster pool.
#[derive(Debug, PartialEq, Hash, Eq, Clone, Default)]
pub struct User {
/// User name.
pub user: String,
/// Database name.
pub database: String,
}

impl From<User> for pgdog_stats::User {
fn from(value: User) -> Self {
Self {
user: value.user,
database: value.database,
}
}
}

impl std::fmt::Display for User {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}/{}", self.user, self.database)
}
}
pub use pgdog_stats::User;

/// Convert to a database/user pair.
pub trait ToUser {
Expand Down
Loading