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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,15 @@
use pyo3::IntoPyObjectExt;
use pyo3::prelude::{Bound, PyAny, PyResult, Python};

use crate::bindings::_helpers::event_exporting::dispatcher::EventExporterDispatcher;
use crate::event_exporting::models::EventExporterDispatcher;
use sqlbuild_python_base::event_exporting::models::BoundEventExporter;
use sqlbuild_python_base::event_exporting::models::EventExportSummary;
use sqlbuild_python_base::event_exporting::models::EventExporterAccounting;
use sqlbuild_python_base::event_exporting::models::EventExporterCommandScope;
use sqlbuild_python_base::event_exporting::models::EventExporterCounts;
use sqlbuild_python_base::event_exporting::models::EventExporterFailure;
use sqlbuild_python_base::records::main::registry::class_of::class_of;
use sqlbuild_python_base::records::models::GetterEntry;

/// The getter readers of this module's native pyclasses.
pub(crate) const GETTERS: &[GetterEntry] = &[
GetterEntry {
class: class_of::<EventExporterDispatcher>,
read: read_event_exporter_dispatcher,
},
GetterEntry {
class: class_of::<BoundEventExporter>,
read: read_bound_event_exporter,
},
GetterEntry {
class: class_of::<EventExportSummary>,
read: read_event_export_summary,
},
GetterEntry {
class: class_of::<EventExporterAccounting>,
read: read_event_exporter_accounting,
},
GetterEntry {
class: class_of::<EventExporterCounts>,
read: read_event_exporter_counts,
},
GetterEntry {
class: class_of::<EventExporterFailure>,
read: read_event_exporter_failure,
},
GetterEntry {
class: class_of::<EventExporterCommandScope>,
read: read_event_exporter_command_scope,
},
];

fn read_event_exporter_dispatcher<'py>(
pub(crate) fn read_event_exporter_dispatcher<'py>(
value: &Bound<'py, PyAny>,
name: &str,
) -> Option<PyResult<Bound<'py, PyAny>>> {
Expand All @@ -63,7 +29,7 @@ fn read_event_exporter_dispatcher<'py>(
})
}

fn read_bound_event_exporter<'py>(
pub(crate) fn read_bound_event_exporter<'py>(
value: &Bound<'py, PyAny>,
name: &str,
) -> Option<PyResult<Bound<'py, PyAny>>> {
Expand All @@ -88,7 +54,7 @@ fn read_bound_event_exporter<'py>(
})
}

fn read_event_export_summary<'py>(
pub(crate) fn read_event_export_summary<'py>(
value: &Bound<'py, PyAny>,
name: &str,
) -> Option<PyResult<Bound<'py, PyAny>>> {
Expand Down Expand Up @@ -116,7 +82,7 @@ fn read_event_export_summary<'py>(
})
}

fn read_event_exporter_accounting<'py>(
pub(crate) fn read_event_exporter_accounting<'py>(
value: &Bound<'py, PyAny>,
name: &str,
) -> Option<PyResult<Bound<'py, PyAny>>> {
Expand All @@ -134,7 +100,7 @@ fn read_event_exporter_accounting<'py>(
})
}

fn read_event_exporter_counts<'py>(
pub(crate) fn read_event_exporter_counts<'py>(
value: &Bound<'py, PyAny>,
name: &str,
) -> Option<PyResult<Bound<'py, PyAny>>> {
Expand All @@ -155,7 +121,7 @@ fn read_event_exporter_counts<'py>(
})
}

fn read_event_exporter_failure<'py>(
pub(crate) fn read_event_exporter_failure<'py>(
value: &Bound<'py, PyAny>,
name: &str,
) -> Option<PyResult<Bound<'py, PyAny>>> {
Expand All @@ -177,7 +143,7 @@ fn read_event_exporter_failure<'py>(
})
}

fn read_event_exporter_command_scope<'py>(
pub(crate) fn read_event_exporter_command_scope<'py>(
value: &Bound<'py, PyAny>,
name: &str,
) -> Option<PyResult<Bound<'py, PyAny>>> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub(crate) mod dispatcher;
pub(crate) mod getters;
pub(crate) mod policy;
pub(crate) mod workers;
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Lifecycle export policy, severity comparison and narrowing for Python callers.

use pyo3::prelude::{
Bound, PyAny, PyModule, PyModuleMethods, PyResult, Python, pyfunction, wrap_pyfunction,
};
use pyo3::prelude::{Bound, PyAny, PyResult, Python, pyfunction};
use pyo3::types::{PyDict, PyDictMethods};
use sqlbuild_core::event_export::main::severity_at_least::severity_at_least;
use sqlbuild_core::event_export::main::stricter_severity::stricter_severity;
Expand All @@ -16,7 +14,7 @@ use sqlbuild_python_base::event_exporting::main::severity_object::severity_objec

/// `{event_type: (kind, severity, priority)}` for every catalogued lifecycle event, in catalogue order.
#[pyfunction]
fn lifecycle_export_policy_catalog(py: Python<'_>) -> PyResult<Bound<'_, PyDict>> {
pub(crate) fn lifecycle_export_policy_catalog(py: Python<'_>) -> PyResult<Bound<'_, PyDict>> {
let policies: Bound<'_, PyDict> = PyDict::new(py);
for definition in catalog(CURRENT_LIFECYCLE_EVENT_SCHEMA_VERSION).unwrap_or_default() {
let event_type: &str = definition.event_type;
Expand All @@ -36,7 +34,7 @@ fn lifecycle_export_policy_catalog(py: Python<'_>) -> PyResult<Bound<'_, PyDict>
/// Whether a catalogued severity meets a configured minimum.
#[pyfunction]
#[pyo3(signature = (*, severity, minimum))]
fn event_export_severity_at_least(
pub(crate) fn event_export_severity_at_least(
severity: &Bound<'_, PyAny>,
minimum: &Bound<'_, PyAny>,
) -> PyResult<bool> {
Expand All @@ -49,16 +47,10 @@ fn event_export_severity_at_least(
/// The stricter of a required and an optional minimum severity, as `EventExportSeverity`.
#[pyfunction]
#[pyo3(signature = (*, first, second))]
fn stricter_event_export_severity<'py>(
pub(crate) fn stricter_event_export_severity<'py>(
first: &Bound<'py, PyAny>,
second: Option<&Bound<'py, PyAny>>,
) -> PyResult<Bound<'py, PyAny>> {
let second: Option<ExportSeverity> = second.map(severity_from).transpose()?;
severity_object(first.py(), stricter_severity(severity_from(first)?, second))
}

pub(crate) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
module.add_function(wrap_pyfunction!(lifecycle_export_policy_catalog, module)?)?;
module.add_function(wrap_pyfunction!(event_export_severity_at_least, module)?)?;
module.add_function(wrap_pyfunction!(stricter_event_export_severity, module)?)
}
Loading
Loading