github.com/sym3tri/etcd@v0.2.1-0.20140422215517-a563d82f95d6/store/v2/sync_command.go (about)

     1  package v2
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/coreos/etcd/store"
     7  	"github.com/coreos/etcd/third_party/github.com/goraft/raft"
     8  )
     9  
    10  func init() {
    11  	raft.RegisterCommand(&SyncCommand{})
    12  }
    13  
    14  type SyncCommand struct {
    15  	Time time.Time `json:"time"`
    16  }
    17  
    18  // The name of the Sync command in the log
    19  func (c SyncCommand) CommandName() string {
    20  	return "etcd:sync"
    21  }
    22  
    23  func (c SyncCommand) Apply(context raft.Context) (interface{}, error) {
    24  	s, _ := context.Server().StateMachine().(store.Store)
    25  	s.DeleteExpiredKeys(c.Time)
    26  
    27  	return nil, nil
    28  }