Browse Source

fix add sync_command.go

Xiang Li 12 years ago
parent
commit
eca433cee5
1 changed files with 29 additions and 0 deletions
  1. 29 0
      store/v2/sync_command.go

+ 29 - 0
store/v2/sync_command.go

@@ -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
+}