Skip to main content

Crate sz_rust_orm_facade

Crate sz_rust_orm_facade 

Source
Expand description

ORM Facade — 统一访问 sz-orm 全家桶

§设计目标

减少 sz-rust-addons-operatesz-rust-sz300 等业务包对 sz-orm-* 子包的穿透依赖。 业务包应通过 sz_rust_orm_facade::* 访问 ORM 功能,而非直接依赖 sz-orm-coresz-orm-authsz-orm-mqttsz-orm-schedulersz-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§

ActiveConfig
Alert
Alert event, produced by SaturationGauge / SlaMonitor and other components when an anomaly is detected, and dispatched downstream (logs, webhooks, etc.) via AlertHook.
AliyunOssStorage
阿里云 OSS 存储后端(Mock 实现
BackpressurePolicy
背压策略
BelongsTo
多对一关系配置
BelongsToMany
多对多关系配置
BuiltQuery
Parameterized query construction result
CronExpr
调度器根级 re-export(供 core 内部 dogfood 使用)
CronScheduler
调度器根级 re-export(供 core 内部 dogfood 使用)
DefaultWebSocketHandler
Default WebSocket handler that tracks connections and echoes messages.
DeleteQuery
DELETE query builder
DistributedRateLimiter
Distributed rate limiter
ErrorBudget
Error budget, based on the SLO target and a sliding time window.
ErrorRateCounter
Error rate counter, based on a sliding time window for error rate statistics.
FixedWindowRateLimiter
Fixed window rate limiter
HasMany
一对多关系配置
HasOne
一对一关系配置
HuaweiObsStorage
华为云 OBS 存储后端(Mock 实现
InMemoryBackend
In-memory backend (simulates Redis)
InMemoryQueue
InsertQuery
INSERT query builder
JwtAuthenticator
Authenticator that issues and verifies real HS256 JWTs.
KafkaConfig
LatencyHistogram
Latency percentile histogram.
LocalStorage
LogAlertHook
A simple implementation that writes alerts to the standard error stream.
MemoryCache
基于内存的缓存实现
Message
消息体
MorphMany
多态一对多配置(父模型侧)
MorphTo
多态反向配置(子模型侧)
MqttConfig
MqttMessage
MqttPlugin
MqttTopic
MultiLevelCache
多级缓存(按顺序查询各级缓存)
NatsConfig
OtelTracer
A compatibility wrapper that exposes the same Tracer interface as the OpenTelemetry SDK but is implemented internally by delegating every call to a SzTracer.
Pool
连接池核心实现
PoolConfig
连接池配置
PoolConfigBuilder
连接池配置构建器
PulsarConfig
QiniuKodoStorage
七牛云 Kodo 存储后端(Mock 实现
QueryDeprecated
Query builder entry point
QueueConfig
RateLimitHeaders
Rate limit response headers
RateLimitResult
RbacAuthorizer
Role-based authorizer backed by a role -> permissions map.
RecordingJobHandler
调度器根级 re-export(供 core 内部 dogfood 使用) JobHandler that 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 实现
SaturationGauge
Saturation alert gauge.
ScheduledTask
调度器根级 re-export(供 core 内部 dogfood 使用)
SelectQuery
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.
SlidingWindowRateLimiter
Span
SpanLog
SqlComplexityScore
SQL complexity score result.
StorageBuilder
StorageConfig
SzTracer
TencentCosStorage
腾讯云 COS 存储后端(Mock 实现
TimestampFields
时间戳字段配置
TokenBucketRateLimiter
UpYunStorage
又拍云存储后端(Mock 实现
UpdateQuery
UPDATE query builder
WhitelistValidator
Whitelist validator that restricts SQL to only access allowed tables and columns.
WsServer

Enums§

AlertLevel
Alert level.
CacheError
缓存特有错误
ComplexityLevel
SQL complexity level.
DbError
数据库错误类型
DbType
支持的数据库类型
MqError
MqProvider
MqttError
OverflowStrategy
溢出处理策略
PoolError
连接池特有错误
QoS
RateLimitError
RateLimitResponseStrategy
Rate limit response strategy
Relation
模型间的关系描述
RelationError
关系操作错误类型 关系加载错误
SchedulerError
调度器根级 re-export(供 core 内部 dogfood 使用)
SqlStatementType
SQL statement type detected by the parser
SqlToken
SQL token type (for simplified AST analysis).
SqlValidationError
SQL validation errors
StorageError
StorageProvider
StorageWrapper
TracingError
Value
数据库值类型
WsError

Traits§

AlertHook
Alert dispatch hook. Implementations can write alerts to logs, send them to a webhook, push them to IM, etc.
Authorizer
Cache
缓存抽象 trait
Connection
数据库连接 trait
ConnectionFactory
连接工厂 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 + Sync because they may be invoked from a background thread.
MessageQueue
消息队列统一抽象
Model
所有 ORM 模型必须实现的核心 trait
ModelExt
模型扩展 trait,提供额外功能
RateLimiter
RateLimiter trait re-export(限流中间件核心 trait)
RelationAccess
ModelExt 的关系访问扩展方法
RelationLoader
可存储已加载关系数据的模型 trait
Scheduler
调度器根级 re-export(供 core 内部 dogfood 使用)
Storage
Tracer
WebSocketHandler

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§

ValidationResult
Result type for SQL validation