1 Star 1 Fork 0

hh/etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
Documentation
Godeps
auth
client
clientv3
compactor
contrib
discovery
e2e
error
etcdctl
etcdctlv3
command
auth_command.go
compaction_command.go
defrag_command.go
del_command.go
doc.go
elect_command.go
error.go
get_command.go
global.go
lease_command.go
lock_command.go
make_mirror_command.go
member_command.go
printer.go
put_command.go
snapshot_command.go
txn_command.go
util.go
version_command.go
watch_command.go
doc
.gitignore
README.md
help.go
main.go
etcdmain
etcdserver
hack
integration
lease
logos
pkg
proxy
raft
rafthttp
scripts
snap
storage
store
tools
version
wal
.dockerignore
.gitignore
.godir
.header
.travis.yml
CONTRIBUTING.md
DCO
Dockerfile
LICENSE
MAINTAINERS
NOTICE
Procfile
README.md
ROADMAP.md
V3DemoProcfile
build
build.bat
cover
main.go
test
克隆/下载
compaction_command.go 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
// Copyright 2015 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package command
import (
"fmt"
"strconv"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra"
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
)
// NewCompactionCommand returns the cobra command for "compaction".
func NewCompactionCommand() *cobra.Command {
return &cobra.Command{
Use: "compaction <revision>",
Short: "Compaction compacts the event history in etcd.",
Run: compactionCommandFunc,
}
}
// compactionCommandFunc executes the "compaction" command.
func compactionCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, fmt.Errorf("compaction command needs 1 argument."))
}
rev, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
ExitWithError(ExitError, err)
}
c := mustClientFromCmd(cmd)
if cerr := c.Compact(context.TODO(), rev); cerr != nil {
ExitWithError(ExitError, cerr)
return
}
fmt.Println("compacted revision", rev)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/w1229748769/etcd.git
git@gitee.com:w1229748769/etcd.git
w1229748769
etcd
etcd
v2.3.0

搜索帮助