1 Star 0 Fork 2

who7708/etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
delete_command.go 836 Bytes
一键复制 编辑 原始数据 按行查看 历史
package v2
import (
"github.com/coreos/etcd/log"
"github.com/coreos/etcd/store"
"github.com/coreos/etcd/third_party/github.com/goraft/raft"
)
func init() {
raft.RegisterCommand(&DeleteCommand{})
}
// The DeleteCommand removes a key from the Store.
type DeleteCommand struct {
Key string `json:"key"`
Recursive bool `json:"recursive"`
Dir bool `json:"dir"`
}
// The name of the delete command in the log
func (c *DeleteCommand) CommandName() string {
return "etcd:delete"
}
// Delete the key
func (c *DeleteCommand) Apply(context raft.Context) (interface{}, error) {
s, _ := context.Server().StateMachine().(store.Store)
if c.Recursive {
// recursive implies dir
c.Dir = true
}
e, err := s.Delete(c.Key, c.Dir, c.Recursive)
if err != nil {
log.Debug(err)
return nil, err
}
return e, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/who7708/etcd.git
git@gitee.com:who7708/etcd.git
who7708
etcd
etcd
v0.4.5

搜索帮助