fix(readme): fix
This commit is contained in:
58
README.md
58
README.md
@@ -392,64 +392,6 @@ classDiagram
|
||||
ERROR
|
||||
FATAL
|
||||
}
|
||||
|
||||
class LogRecord {
|
||||
+String service_name
|
||||
+DateTime timestamp
|
||||
+LogLevel level
|
||||
+String message
|
||||
+String module
|
||||
+Option<String> trace_id
|
||||
}
|
||||
%% 接口定义:强调 Send + Sync 约束
|
||||
class LogOutput {
|
||||
<<interface>>
|
||||
<<Send + Sync>>
|
||||
+write(record: LogRecord) Future
|
||||
}
|
||||
|
||||
%% 具体实现
|
||||
class PostgresOutput {
|
||||
-PgPool pool
|
||||
+write(record)
|
||||
}
|
||||
class ConsoleOutput {
|
||||
+write(record)
|
||||
}
|
||||
|
||||
%% 业务线程持有的 Logger (Producer)
|
||||
class Logger {
|
||||
<<Thread-Safe>>
|
||||
<<Shared via Arc>>
|
||||
-mpsc::Sender~LogRecord~ tx
|
||||
-LogLevel min_level
|
||||
+log(level, msg)
|
||||
}
|
||||
|
||||
%% 后台异步任务 (Consumer)
|
||||
class BackgroundWorker {
|
||||
<<Active Object>>
|
||||
<<Running in tokio::spawn>>
|
||||
-mpsc::Receiver~LogRecord~ rx
|
||||
-Vec~Box~LogOutput~~ outputs
|
||||
+run()
|
||||
}
|
||||
|
||||
|
||||
%% 关系描述
|
||||
LogOutput <|.. PostgresOutput
|
||||
LogOutput <|.. ConsoleOutput
|
||||
|
||||
%% 关键的线程安全机制:MPSC Channel
|
||||
Logger "1" o-- "1" `mpsc::Sender` : Owns
|
||||
BackgroundWorker "1" o-- "1" `mpsc::Receiver` : Owns
|
||||
|
||||
%% 逻辑流
|
||||
ClientThread ..> Logger : 1. Calls log() (Non-blocking)
|
||||
Logger ..> `mpsc::Sender` : 2. Sends Record
|
||||
`mpsc::Sender` ..> `mpsc::Receiver` : 3. Channel Transfer (Thread-Safe)
|
||||
`mpsc::Receiver` ..> BackgroundWorker : 4. Receives Record
|
||||
BackgroundWorker --> LogOutput : 5. Serialized Writes
|
||||
```
|
||||
|
||||
</details>
|
||||
Reference in New Issue
Block a user