Skip to content

Commit

Permalink
Merge pull request #5083 from systeminit/nick/9dc7644
Browse files Browse the repository at this point in the history
Split `audit-logs` crate into two crates
  • Loading branch information
nickgerace authored Dec 7, 2024
2 parents f0f295f + ee3b4c7 commit b97e8a2
Show file tree
Hide file tree
Showing 42 changed files with 178 additions and 111 deletions.
29 changes: 20 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ members = [
"bin/sdf",
"bin/veritech",
"lib/asset-sprayer",
"lib/audit-logs",
"lib/audit-database",
"lib/audit-logs-stream",
"lib/auth-api-client",
"lib/billing-events",
"lib/buck2-resources",
Expand Down
5 changes: 1 addition & 4 deletions lib/audit-logs/BUCK → lib/audit-database/BUCK
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
load("@prelude-si//:macros.bzl", "rust_library")

rust_library(
name = "audit-logs",
name = "audit-database",
deps = [
"//lib/si-data-nats:si-data-nats",
"//lib/si-data-pg:si-data-pg",
"//lib/si-events-rs:si-events",
"//lib/telemetry-nats-rs:telemetry-nats",
"//lib/telemetry-rs:telemetry",
"//third-party/rust:chrono",
"//third-party/rust:refinery",
"//third-party/rust:remain",
"//third-party/rust:serde",
"//third-party/rust:serde_json",
"//third-party/rust:strum",
"//third-party/rust:thiserror",
],
srcs = glob([
Expand Down
5 changes: 1 addition & 4 deletions lib/audit-logs/Cargo.toml → lib/audit-database/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "audit-logs"
name = "audit-database"
edition = "2021"
version.workspace = true
authors.workspace = true
Expand All @@ -9,16 +9,13 @@ rust-version.workspace = true
publish.workspace = true

[dependencies]
si-data-nats = { path = "../../lib/si-data-nats" }
si-data-pg = { path = "../../lib/si-data-pg" }
si-events = { path = "../../lib/si-events-rs" }
telemetry = { path = "../../lib/telemetry-rs" }
telemetry-nats = { path = "../../lib/telemetry-nats-rs" }

chrono = { workspace = true }
refinery = { workspace = true }
remain = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
strum = { workspace = true }
thiserror = { workspace = true }
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use thiserror::Error;
use super::AuditDatabaseConfig;

#[allow(missing_docs)]
#[remain::sorted]
#[derive(Error, Debug)]
pub enum AuditDatabaseContextError {
#[error("pg pool error: {0}")]
Expand Down
28 changes: 27 additions & 1 deletion lib/audit-logs/src/database.rs → lib/audit-database/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
//! Contains functionality for setting up and communicating with the audit database.
//! This crate contains functionality for setting up and communicating with the audit database.
#![warn(
bad_style,
clippy::missing_panics_doc,
clippy::panic,
clippy::panic_in_result_fn,
clippy::unwrap_in_result,
clippy::unwrap_used,
dead_code,
improper_ctypes,
missing_debug_implementations,
missing_docs,
no_mangle_generic_items,
non_shorthand_field_patterns,
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
unconditional_recursion,
unreachable_pub,
unused,
unused_allocation,
unused_comparisons,
unused_parens,
while_true
)]

use std::str::FromStr;

Expand Down Expand Up @@ -31,6 +56,7 @@ pub use context::AuditDatabaseContextError;
pub use migrate::{migrate, AuditDatabaseMigrationError};

#[allow(missing_docs)]
#[remain::sorted]
#[derive(Error, Debug)]
pub enum AuditDatabaseError {
#[error("chrono parse error: {0}")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use thiserror::Error;
use super::AuditDatabaseContext;

#[allow(missing_docs)]
#[remain::sorted]
#[derive(Error, Debug)]
pub enum AuditDatabaseMigrationError {
#[error("pg pool error: {0}")]
Expand Down
14 changes: 14 additions & 0 deletions lib/audit-logs-stream/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@prelude-si//:macros.bzl", "rust_library")

rust_library(
name = "audit-logs-stream",
deps = [
"//lib/si-data-nats:si-data-nats",
"//lib/si-events-rs:si-events",
"//lib/telemetry-rs:telemetry",
"//third-party/rust:remain",
"//third-party/rust:serde_json",
"//third-party/rust:thiserror",
],
srcs = glob(["src/**/*.rs"]),
)
18 changes: 18 additions & 0 deletions lib/audit-logs-stream/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "audit-logs-stream"
edition = "2021"
version.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
publish.workspace = true

[dependencies]
si-data-nats = { path = "../../lib/si-data-nats" }
si-events = { path = "../../lib/si-events-rs" }
telemetry = { path = "../../lib/telemetry-rs" }

remain = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
//! This module provides the ability to work with the audit logs stream.
//! This crate provides the ability to work with the audit logs stream.
#![warn(
bad_style,
clippy::missing_panics_doc,
clippy::panic,
clippy::panic_in_result_fn,
clippy::unwrap_in_result,
clippy::unwrap_used,
dead_code,
improper_ctypes,
missing_debug_implementations,
missing_docs,
no_mangle_generic_items,
non_shorthand_field_patterns,
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
unconditional_recursion,
unreachable_pub,
unused,
unused_allocation,
unused_comparisons,
unused_parens,
while_true
)]

use std::time::Duration;

Expand Down
32 changes: 0 additions & 32 deletions lib/audit-logs/src/lib.rs

This file was deleted.

2 changes: 1 addition & 1 deletion lib/dal-test/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@prelude-si//:macros.bzl", "rust_library")
rust_library(
name = "dal-test",
deps = [
"//lib/audit-logs:audit-logs",
"//lib/audit-database:audit-database",
"//lib/buck2-resources:buck2-resources",
"//lib/dal:dal",
"//lib/forklift-server:forklift-server",
Expand Down
37 changes: 19 additions & 18 deletions lib/dal-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,13 @@ rust-version.workspace = true
publish.workspace = true

[dependencies]
async-recursion = { workspace = true }
audit-logs = { path = "../../lib/audit-logs" }
base64 = { workspace = true }
audit-database = { path = "../../lib/audit-database" }
buck2-resources = { path = "../../lib/buck2-resources" }
color-eyre = { workspace = true }
dal = { path = "../../lib/dal" }
derive_builder = { workspace = true }
derive_more = { workspace = true }
forklift-server = { path = "../../lib/forklift-server" }
jwt-simple = { workspace = true }
lazy_static = { workspace = true }
names = { workspace = true }
opentelemetry-otlp = { workspace = true }
opentelemetry_sdk = { workspace = true }
pinga-server = { path = "../../lib/pinga-server" }
rebaser-client = { path = "../../lib/rebaser-client" }
rebaser-server = { path = "../../lib/rebaser-server" }
remain = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
si-crypto = { path = "../../lib/si-crypto" }
si-data-nats = { path = "../../lib/si-data-nats" }
si-data-pg = { path = "../../lib/si-data-pg" }
Expand All @@ -38,8 +25,25 @@ si-pkg = { path = "../../lib/si-pkg" }
si-runtime = { path = "../../lib/si-runtime-rs" }
si-std = { path = "../../lib/si-std" }
si-test-macros = { path = "../../lib/si-test-macros" }
sodiumoxide = { workspace = true }
telemetry = { path = "../../lib/telemetry-rs" }
veritech-client = { path = "../../lib/veritech-client" }
veritech-server = { path = "../../lib/veritech-server" }

async-recursion = { workspace = true }
base64 = { workspace = true }
color-eyre = { workspace = true }
derive_builder = { workspace = true }
derive_more = { workspace = true }
itertools = { workspace = true }
jwt-simple = { workspace = true }
lazy_static = { workspace = true }
names = { workspace = true }
opentelemetry-otlp = { workspace = true }
opentelemetry_sdk = { workspace = true }
remain = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sodiumoxide = { workspace = true }
tempfile = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
Expand All @@ -48,6 +52,3 @@ tracing-opentelemetry = { workspace = true }
tracing-subscriber = { workspace = true }
ulid = { workspace = true }
uuid = { workspace = true }
veritech-client = { path = "../../lib/veritech-client" }
veritech-server = { path = "../../lib/veritech-server" }
itertools = { workspace = true }
2 changes: 1 addition & 1 deletion lib/dal-test/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::time::Duration;

use audit_logs::database::{AuditDatabaseContext, AuditLogRow};
use audit_database::{AuditDatabaseContext, AuditLogRow};
use color_eyre::eyre::eyre;
use color_eyre::Result;
use dal::component::socket::{ComponentInputSocket, ComponentOutputSocket};
Expand Down
6 changes: 3 additions & 3 deletions lib/dal-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use std::{
sync::{Arc, Once},
};

use audit_logs::database::AuditDatabaseContext;
use audit_database::AuditDatabaseContext;
use buck2_resources::Buck2Resources;
use dal::{
builtins::func,
Expand Down Expand Up @@ -177,7 +177,7 @@ pub struct Config {
symmetric_crypto_service_config: SymmetricCryptoServiceConfig,
#[builder(default = "si_layer_cache::default_pg_pool_config()")]
layer_cache_pg_pool: PgPoolConfig,
#[builder(default = "audit_logs::database::default_pg_pool_config()")]
#[builder(default = "audit_database::default_pg_pool_config()")]
audit_pg_pool: PgPoolConfig,
}

Expand Down Expand Up @@ -837,7 +837,7 @@ async fn global_setup(test_context_builer: TestContextBuilder) -> Result<()> {
.pg_migrate()
.await
.wrap_err("failed to migrate layerdb")?;
audit_logs::database::migrate(&test_context.audit_database_context)
audit_database::migrate(&test_context.audit_database_context)
.await
.wrap_err("failed to migrate audit database")?;
}
Expand Down
Loading

0 comments on commit b97e8a2

Please sign in to comment.