67ee76e58d
Deploy Slides / build-and-deploy (push) Successful in 1m8s
- Add 5 new slide pages: eino-deep-dive, ratelimit-overview, ratelimit-lua, async-deep-dive, harness - Add 4 new drawio SVGs: pipeline-detail, ratelimit, async-task, harness - Update all existing slides with v-clicks progressive reveal - Add presenter notes and interactive prompts - Expand slides.md to register all new pages (16 → 25+ slides) - Fix text overflow by trimming content per Item block - Add Eino Graph deep dive: WithGenLocalState, Pre/Post Handler, branch routing - Add rate limiting section: algorithm comparison, Lua script, Gin middleware - Add async task deep dive: TaskQueue FIFO, context progress injection - Add consistency section: style/pipeline/data/deployment 4-layer guarantees
1.9 KiB
1.9 KiB
异步任务 — 队列与调度
FIFO 串行执行,信号驱动调度
type TaskQueue struct {
mu sync.Mutex
jobs []*TaskJob
ready chan struct{} // 新任务到达信号
stop chan struct{} // 优雅关闭信号
}
func (q *TaskQueue) Enqueue(job *TaskJob) {
q.mu.Lock()
q.jobs = append(q.jobs, job)
q.mu.Unlock()
q.ready <- struct{}{} // 唤醒 run() 协程
}
进度推送与 WebSocket
Context 注入 + 多通道推送
func WithProgressReporter(ctx context.Context, r ProgressReporter) context.Context {
return context.WithValue(ctx, progressCtxKey, r)
}
// 管线节点中使用
reporter := GetProgressReporter(ctx)
reporter.Report(Progress{Stage: "prompt", Percent: 25})