1 Star 1 Fork 0

hh/etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
event.go 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
package raft
const (
StateChangeEventType = "stateChange"
LeaderChangeEventType = "leaderChange"
TermChangeEventType = "termChange"
CommitEventType = "commit"
AddPeerEventType = "addPeer"
RemovePeerEventType = "removePeer"
RemovedEventType = "removed"
HeartbeatIntervalEventType = "heartbeatInterval"
ElectionTimeoutThresholdEventType = "electionTimeoutThreshold"
HeartbeatEventType = "heartbeat"
)
// Event represents an action that occurred within the Raft library.
// Listeners can subscribe to event types by using the Server.AddEventListener() function.
type Event interface {
Type() string
Source() interface{}
Value() interface{}
PrevValue() interface{}
}
// event is the concrete implementation of the Event interface.
type event struct {
typ string
source interface{}
value interface{}
prevValue interface{}
}
// newEvent creates a new event.
func newEvent(typ string, value interface{}, prevValue interface{}) *event {
return &event{
typ: typ,
value: value,
prevValue: prevValue,
}
}
// Type returns the type of event that occurred.
func (e *event) Type() string {
return e.typ
}
// Source returns the object that dispatched the event.
func (e *event) Source() interface{} {
return e.source
}
// Value returns the current value associated with the event, if applicable.
func (e *event) Value() interface{} {
return e.value
}
// PrevValue returns the previous value associated with the event, if applicable.
func (e *event) PrevValue() interface{} {
return e.prevValue
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/w1229748769/etcd.git
git@gitee.com:w1229748769/etcd.git
w1229748769
etcd
etcd
v0.4.8

搜索帮助