删除任务链(drafts/confirmations/tasks/attempts)、creator 运营链(策略/事件/操作/会话/消息/监听器/素材/关系)、runtime_use_lease 机制及其 API/UI;taskstate 包与对应测试一并移除。
40 lines
789 B
Go
40 lines
789 B
Go
package api
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// creatorUpdateHub 向 SSE 订阅者广播运营数据变更通知。
|
|
type creatorUpdateHub struct {
|
|
mu sync.Mutex
|
|
subscribers map[chan struct{}]struct{}
|
|
}
|
|
|
|
var creatorUpdates = &creatorUpdateHub{subscribers: make(map[chan struct{}]struct{})}
|
|
|
|
func (h *creatorUpdateHub) subscribe() (<-chan struct{}, func()) {
|
|
channel := make(chan struct{}, 1)
|
|
h.mu.Lock()
|
|
h.subscribers[channel] = struct{}{}
|
|
h.mu.Unlock()
|
|
return channel, func() {
|
|
h.mu.Lock()
|
|
if _, ok := h.subscribers[channel]; ok {
|
|
delete(h.subscribers, channel)
|
|
close(channel)
|
|
}
|
|
h.mu.Unlock()
|
|
}
|
|
}
|
|
|
|
func (h *creatorUpdateHub) publish() {
|
|
h.mu.Lock()
|
|
defer h.mu.Unlock()
|
|
for channel := range h.subscribers {
|
|
select {
|
|
case channel <- struct{}{}:
|
|
default:
|
|
}
|
|
}
|
|
}
|