fix add sync_command.go

This commit is contained in:
Xiang Li 2013-11-09 18:59:43 -08:00
parent 6156d5c790
commit eca433cee5

29
store/v2/sync_command.go Normal file
View 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
}