Expand description
ORM Facade — 统一访问 sz-orm 全家桶
§设计目标
减少 sz-rust-addons-operate、sz-rust-sz300 等业务包对 sz-orm-* 子包的穿透依赖。
业务包应通过 sz_rust_orm_facade::* 访问 ORM 功能,而非直接依赖 sz-orm-core、
sz-orm-auth、sz-orm-mqtt、sz-orm-scheduler、sz-orm-logger。
§使用示例
ⓘ
// 业务包统一通过 facade 访问(推荐)
use sz_rust_orm_facade::{Pool, Value, Model, ModelExt, Authorizer, JwtAuthenticator, MqttConfig, QoS};
use sz_rust_orm_facade::repository::{Repository, WhereCondition, WhereOp};
use sz_rust_orm_facade::scheduler::{CronScheduler, JobHandler, ScheduledTask, Scheduler};Re-exports§
pub use pool_config::SqlxPoolConfig;pub use pool_scaler::PoolMetrics;pub use pool_scaler::PoolScaler;pub use pool_scaler::PoolScalerConfig;pub use pool_warmer::PoolWarmer;pub use pool_warmer::WarmupError as PoolWarmupError;pub use query_cache::QueryCache;pub use query_cache::QueryCacheConfig;pub use query_cache::QueryCacheError;pub use jobs::Job;pub use jobs::JobError;pub use jobs::JobErrorKind;pub use jobs::JobQueue;pub use jobs::JobQueueConfig;pub use jobs::JobQueueError;pub use jobs::JobStatus;pub use jobs::QueueSnapshot;pub use jobs::TaskHandler;pub use jobs::JOBS_TABLE;
Modules§
- auth
- 认证子模块(Credentials / User / Claims 等数据结构)
- data_
scope - 数据范围控制 Data Scope — 应用层行级数据过滤
- find_
with_ related - 关联查询子模块(find_with_related eager/join/subquery 策略)
- hooks
- Hooks 子模块(生命周期钩子)
- jobs
- 可靠任务队列(Reliable Job Queue)
- jwt
- JWT 子模块(JwtEncoder / JwtClaims 等编码工具)
- l2_
cache - L2 缓存子模块(二级缓存共享层)
- logger
- 日志子模块(Logger / LogEntry / LogLevel 等)
- migration
- 迁移子模块(schema migration)
- pool_
config - 连接池配置调优(L2 方案:sqlx 配置调优,不修改 sz-orm 上游)
- pool_
scaler - PoolScaler — 连接池动态扩容(P3 L3 调优)
- pool_
warmer - PoolWarmer — 连接池预热(P3 L3 调优)
- query_
cache - QueryCache — L2 查询缓存(P3 L3 调优)
- repository
- 仓储子模块(Repository trait + WhereCondition/WhereOp 条件构造)
- scheduler
- 调度器子模块(CronScheduler / JobHandler / ScheduledTask 等)
Macros§
- query
- Compile-time SQL validation with optional real DB verification.
- sql_
string - Compile-time SQL validation macro.
Structs§
- Active
Config - Alert
- Alert event, produced by
SaturationGauge/SlaMonitorand other components when an anomaly is detected, and dispatched downstream (logs, webhooks, etc.) viaAlertHook. - Aliyun
OssStorage - 阿里云 OSS 存储后端(Mock 实现)
- Backpressure
Policy - 背压策略
- Belongs
To - 多对一关系配置
- Belongs
ToMany - 多对多关系配置
- Built
Query - Parameterized query construction result
- Cron
Expr - 调度器根级 re-export(供 core 内部 dogfood 使用)
- Cron
Scheduler - 调度器根级 re-export(供 core 内部 dogfood 使用)
- Default
WebSocket Handler - Default WebSocket handler that tracks connections and echoes messages.
- Delete
Query - DELETE query builder
- Distributed
Rate Limiter - Distributed rate limiter
- Error
Budget - Error budget, based on the SLO target and a sliding time window.
- Error
Rate Counter - Error rate counter, based on a sliding time window for error rate statistics.
- Fixed
Window Rate Limiter - Fixed window rate limiter
- HasMany
- 一对多关系配置
- HasOne
- 一对一关系配置
- Huawei
ObsStorage - 华为云 OBS 存储后端(Mock 实现)
- InMemory
Backend - In-memory backend (simulates Redis)
- InMemory
Queue - Insert
Query - INSERT query builder
- JwtAuthenticator
- Authenticator that issues and verifies real HS256 JWTs.
- Kafka
Config - Latency
Histogram - Latency percentile histogram.
- Local
Storage - LogAlert
Hook - A simple implementation that writes alerts to the standard error stream.
- Memory
Cache - 基于内存的缓存实现
- Message
- 消息体
- Morph
Many - 多态一对多配置(父模型侧)
- MorphTo
- 多态反向配置(子模型侧)
- Mqtt
Config - Mqtt
Message - Mqtt
Plugin - Mqtt
Topic - Multi
Level Cache - 多级缓存(按顺序查询各级缓存)
- Nats
Config - Otel
Tracer - A compatibility wrapper that exposes the same
Tracerinterface as the OpenTelemetry SDK but is implemented internally by delegating every call to aSzTracer. - Pool
- 连接池核心实现
- Pool
Config - 连接池配置
- Pool
Config Builder - 连接池配置构建器
- Pulsar
Config - Qiniu
Kodo Storage - 七牛云 Kodo 存储后端(Mock 实现)
- Query
Deprecated - Query builder entry point
- Queue
Config - Rate
Limit Headers - Rate limit response headers
- Rate
Limit Result - Rbac
Authorizer - Role-based authorizer backed by a
role -> permissionsmap. - Recording
JobHandler - 调度器根级 re-export(供 core 内部 dogfood 使用)
JobHandlerthat records the IDs of every task it has handled, in the order they were handled. Useful for tests that need to assert which tasks fired and in what order. - S3Storage
- AWS S3 存储后端(Mock 实现)
- Saturation
Gauge - Saturation alert gauge.
- Scheduled
Task - 调度器根级 re-export(供 core 内部 dogfood 使用)
- Select
Query - SELECT query builder
- SlaMonitor
- SLA monitor, aggregates latency and error statistics by operation name, and generates
SlaReport. - SlaReport
- SLA monitoring report snapshot, generated by
SlaMonitor::report. - Sliding
Window Rate Limiter - Span
- SpanLog
- SqlComplexity
Score - SQL complexity score result.
- Storage
Builder - Storage
Config - SzTracer
- Tencent
CosStorage - 腾讯云 COS 存储后端(Mock 实现)
- Timestamp
Fields - 时间戳字段配置
- Token
Bucket Rate Limiter - UpYun
Storage - 又拍云存储后端(Mock 实现)
- Update
Query - UPDATE query builder
- Whitelist
Validator - Whitelist validator that restricts SQL to only access allowed tables and columns.
- WsServer
Enums§
- Alert
Level - Alert level.
- Cache
Error - 缓存特有错误
- Complexity
Level - SQL complexity level.
- DbError
- 数据库错误类型
- DbType
- 支持的数据库类型
- MqError
- MqProvider
- Mqtt
Error - Overflow
Strategy - 溢出处理策略
- Pool
Error - 连接池特有错误
- QoS
- Rate
Limit Error - Rate
Limit Response Strategy - Rate limit response strategy
- Relation
- 模型间的关系描述
- Relation
Error - 关系操作错误类型 关系加载错误
- Scheduler
Error - 调度器根级 re-export(供 core 内部 dogfood 使用)
- SqlStatement
Type - SQL statement type detected by the parser
- SqlToken
- SQL token type (for simplified AST analysis).
- SqlValidation
Error - SQL validation errors
- Storage
Error - Storage
Provider - Storage
Wrapper - Tracing
Error - Value
- 数据库值类型
- WsError
Traits§
- Alert
Hook - Alert dispatch hook. Implementations can write alerts to logs, send them to a webhook, push them to IM, etc.
- Authorizer
- Cache
- 缓存抽象 trait
- Connection
- 数据库连接 trait
- Connection
Factory - 连接工厂 trait,用于创建新连接
- JobHandler
- 调度器根级 re-export(供 core 内部 dogfood 使用)
Handler invoked by the scheduler when a task’s cron expression matches
the current time. Implementations must be
Send + Syncbecause they may be invoked from a background thread. - Message
Queue - 消息队列统一抽象
- Model
- 所有 ORM 模型必须实现的核心 trait
- Model
Ext - 模型扩展 trait,提供额外功能
- Rate
Limiter - RateLimiter trait re-export(限流中间件核心 trait)
- Relation
Access ModelExt的关系访问扩展方法- Relation
Loader - 可存储已加载关系数据的模型 trait
- Scheduler
- 调度器根级 re-export(供 core 内部 dogfood 使用)
- Storage
- Tracer
- WebSocket
Handler
Functions§
- detect_
statement_ type - Detect the type of SQL statement
- validate
- Entry-level validation that runs all checks
- validate_
column_ name - Validate column name is a valid SQL identifier
- validate_
delete - Validate a SQL DELETE statement
- validate_
insert - Validate a SQL INSERT statement
- validate_
parameter_ count - Validate parameter count in prepared statements
- validate_
select - Validate a SQL SELECT statement
- validate_
sql - Validate any SQL statement by detecting its type and applying appropriate rules
- validate_
table_ name - Validate table name is a valid SQL identifier
- validate_
update - Validate a SQL UPDATE statement
- value_
to_ json - 将 Value 转换为 serde_json::Value(递归处理 Array)
Type Aliases§
- Validation
Result - Result type for SQL validation