Documentation
¶
Index ¶
- func DoTrace(ctx context.Context, a *Actor, scope TraceScope, fn func(*sql.DB) error) error
- func DoValue[T any](ctx context.Context, a *Actor, fn func(*sql.DB) (T, error)) (T, error)
- func DoValueTrace[T any](ctx context.Context, a *Actor, scope TraceScope, fn func(*sql.DB) (T, error)) (T, error)
- func SetTraceSink(sink TraceSink)
- func TxTrace(ctx context.Context, a *Actor, scope TraceScope, fn func(*sql.Tx) error) error
- func TxValue[T any](ctx context.Context, a *Actor, fn func(*sql.Tx) (T, error)) (T, error)
- func TxValueTrace[T any](ctx context.Context, a *Actor, scope TraceScope, fn func(*sql.Tx) (T, error)) (T, error)
- func WithTraceScope(scope TraceScope, fn func())
- type Actor
- type Opened
- type TraceEvent
- type TraceScope
- type TraceSink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoValueTrace ¶
func SetTraceSink ¶
func SetTraceSink(sink TraceSink)
func TxValueTrace ¶
func WithTraceScope ¶
func WithTraceScope(scope TraceScope, fn func())
Types ¶
type Opened ¶
type Opened struct {
// DB 只保留给迁移中的旧访问点使用。
// 设计说明:
// - 新代码必须优先走 Actor;
// - 这轮改造还没把所有 sqlite 访问点一次性迁完,所以先把 owner actor 立起来,
// 再逐步清掉旧的裸 DB 调用;
// - 这里显式保留 DB 字段,是为了让迁移期间能编译通过,而不是鼓励继续扩散裸 DB 写法。
DB *sql.DB
// Actor 是正式入口。
// 规则:
// - 所有新的运行时代码都应该通过 Actor 串行执行;
// - 不允许把 Rows / Tx / Stmt 带出闭包,否则会重新引入生命周期失控问题。
Actor *Actor
}
type TraceEvent ¶
type TraceEvent struct {
TS string `json:"ts"`
Operation string `json:"operation"`
SQL string `json:"sql"`
SQLFingerprint string `json:"sql_fingerprint"`
Args []any `json:"args,omitempty"`
ElapsedMS int64 `json:"elapsed_ms"`
RowsAffected int64 `json:"rows_affected"`
Err string `json:"err,omitempty"`
RoundID string `json:"round_id,omitempty"`
Trigger string `json:"trigger,omitempty"`
Intent string `json:"intent,omitempty"`
Stage string `json:"stage,omitempty"`
CallerChain []string `json:"caller_chain,omitempty"`
}
TraceEvent 是单条 SQL 的追踪记录。
Click to show internal directories.
Click to hide internal directories.