Backend
Landscape
BoltDB Backend
Landscape
run
启动 Timer,定时提交;或者在收到停止信号时,提交并退出。代码很简单,如下所示
func (b *backend) run() {
defer close(b.donec)
t := time.NewTimer(b.batchInterval)
defer t.Stop()
for {
select {
case <-t.C:
case <-b.stopc:
b.batchTx.CommitAndStop()
return
}
b.batchTx.Commit()
t.Reset(b.batchInterval)
}
}
Transaction Relationship
Buffer
MVCC
Store
References
Watchable
Landscape
Watcher Creation
通过 watchStream 创建的全部 watcher 的 ch 全部指向了 watchStream.ch。事件走向为 watcher -> watchStream。watcher 管理由 watcherGroup 负责