mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix add sync_command.go
This commit is contained in:
parent
6156d5c790
commit
eca433cee5
29
store/v2/sync_command.go
Normal file
29
store/v2/sync_command.go
Normal file
@ -0,0 +1,29 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/store"
|
||||
"github.com/coreos/go-raft"
|
||||
)
|
||||
|
||||
func init() {
|
||||
raft.RegisterCommand(&SyncCommand{})
|
||||
}
|
||||
|
||||
type SyncCommand struct {
|
||||
Time time.Time `json:"time"`
|
||||
}
|
||||
|
||||
// The name of the Sync command in the log
|
||||
func (c SyncCommand) CommandName() string {
|
||||
return "etcd:sync"
|
||||
}
|
||||
|
||||
func (c SyncCommand) Apply(server raft.Server) (interface{}, error) {
|
||||
|
||||
s, _ := server.StateMachine().(store.Store)
|
||||
s.DeleteExpiredKeys(c.Time)
|
||||
|
||||
return nil, nil
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user