sync_command.go 483 B

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