Skip to content
Snippets Groups Projects
Commit 793999c6 authored by Andrey Strochuk's avatar Andrey Strochuk
Browse files

feat: add timeout() for AclOwned and DdlOwned

parent 83e269eb
No related branches found
No related tags found
1 merge request!493feat: implement subarenas
......@@ -20,6 +20,32 @@ pub enum AclOwned {
RevokePrivilege(RevokePrivilege),
}
impl AclOwned {
/// Return ACL node timeout.
///
/// # Errors
/// - timeout parsing error
pub fn timeout(&self) -> Result<f64, SbroadError> {
match self {
AclOwned::DropRole(DropRole { ref timeout, .. })
| AclOwned::DropUser(DropUser { ref timeout, .. })
| AclOwned::CreateRole(CreateRole { ref timeout, .. })
| AclOwned::AlterUser(AlterUser { ref timeout, .. })
| AclOwned::CreateUser(CreateUser { ref timeout, .. })
| AclOwned::RevokePrivilege(RevokePrivilege { ref timeout, .. })
| AclOwned::GrantPrivilege(GrantPrivilege { ref timeout, .. }) => timeout,
}
.to_smolstr()
.parse()
.map_err(|e| {
SbroadError::Invalid(
Entity::SpaceMetadata,
Some(format_smolstr!("timeout parsing error {e:?}")),
)
})
}
}
impl From<AclOwned> for SizeNode {
fn from(value: AclOwned) -> Self {
match value {
......
......@@ -23,6 +23,35 @@ pub enum DdlOwned {
SetTransaction(SetTransaction),
}
impl DdlOwned {
/// Return DDL node timeout.
///
/// # Errors
/// - timeout parsing error
pub fn timeout(&self) -> Result<f64, SbroadError> {
match self {
DdlOwned::CreateTable(CreateTable { ref timeout, .. })
| DdlOwned::DropTable(DropTable { ref timeout, .. })
| DdlOwned::CreateIndex(CreateIndex { ref timeout, .. })
| DdlOwned::DropIndex(DropIndex { ref timeout, .. })
| DdlOwned::SetParam(SetParam { ref timeout, .. })
| DdlOwned::SetTransaction(SetTransaction { ref timeout, .. })
| DdlOwned::AlterSystem(AlterSystem { ref timeout, .. })
| DdlOwned::CreateProc(CreateProc { ref timeout, .. })
| DdlOwned::DropProc(DropProc { ref timeout, .. })
| DdlOwned::RenameRoutine(RenameRoutine { ref timeout, .. }) => timeout,
}
.to_smolstr()
.parse()
.map_err(|e| {
SbroadError::Invalid(
Entity::SpaceMetadata,
Some(format_smolstr!("timeout parsing error {e:?}")),
)
})
}
}
impl From<DdlOwned> for SizeNode {
fn from(value: DdlOwned) -> Self {
match value {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment