MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / leaderEventLoop

Method leaderEventLoop

controller/controller.go:156–178  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154}
155
156func (c *Controller) leaderEventLoop() {
157 defer c.wg.Done()
158 for {
159 select {
160 case event := <-c.clusterStore.Notify():
161 if !c.clusterStore.IsLeader() || event.Type != store.EventCluster {
162 continue
163 }
164 switch event.Command {
165 case store.CommandCreate:
166 c.addCluster(event.Namespace, event.Cluster)
167 case store.CommandRemove:
168 c.removeCluster(event.Namespace, event.Cluster)
169 case store.CommandUpdate:
170 c.updateCluster(event.Namespace, event.Cluster)
171 default:
172 logger.Get().Error("Unknown command", zap.Any("event", event))
173 }
174 case <-c.closeCh:
175 return
176 }
177 }
178}
179
180func (c *Controller) buildClusterKey(namespace, clusterName string) string {
181 return namespace + "/" + clusterName

Callers 1

StartMethod · 0.95

Calls 7

addClusterMethod · 0.95
removeClusterMethod · 0.95
updateClusterMethod · 0.95
GetFunction · 0.92
NotifyMethod · 0.80
IsLeaderMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected