mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
29 lines
526 B
Go
29 lines
526 B
Go
package v2
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/coreos/etcd/store"
|
|
"github.com/coreos/etcd/third_party/github.com/goraft/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(context raft.Context) (interface{}, error) {
|
|
s, _ := context.Server().StateMachine().(store.Store)
|
|
s.DeleteExpiredKeys(c.Time)
|
|
|
|
return nil, nil
|
|
}
|