*: fix based on gosimple and unused
parent
9aec045fce
commit
fb85da92e8
|
@ -45,16 +45,6 @@ func NewUniqueKV(ctx context.Context, kv v3.KV, pfx, val string, opts ...v3.OpOp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitUpdate(ctx context.Context, client *v3.Client, key string, opts ...v3.OpOption) error {
|
|
||||||
cctx, cancel := context.WithCancel(ctx)
|
|
||||||
defer cancel()
|
|
||||||
wresp, ok := <-client.Watch(cctx, key, opts...)
|
|
||||||
if !ok {
|
|
||||||
return ctx.Err()
|
|
||||||
}
|
|
||||||
return wresp.Err()
|
|
||||||
}
|
|
||||||
|
|
||||||
func waitDelete(ctx context.Context, client *v3.Client, key string, rev int64) error {
|
func waitDelete(ctx context.Context, client *v3.Client, key string, rev int64) error {
|
||||||
cctx, cancel := context.WithCancel(ctx)
|
cctx, cancel := context.WithCancel(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
@ -81,9 +81,11 @@ func restoreEtcd() error {
|
||||||
return runCommands(10, 2*time.Second)
|
return runCommands(10, 2*time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
var clusterHealthRegex = regexp.MustCompile(".*cluster is healthy.*")
|
var (
|
||||||
var lineSplit = regexp.MustCompile("\n+")
|
clusterHealthRegex = regexp.MustCompile(".*cluster is healthy.*")
|
||||||
var colonSplit = regexp.MustCompile("\\:")
|
lineSplit = regexp.MustCompile("\n+")
|
||||||
|
colonSplit = regexp.MustCompile(`\:`)
|
||||||
|
)
|
||||||
|
|
||||||
func runCommands(maxRetry int, interval time.Duration) error {
|
func runCommands(maxRetry int, interval time.Duration) error {
|
||||||
var retryCnt int
|
var retryCnt int
|
||||||
|
|
|
@ -104,7 +104,7 @@ func handleClusterHealth(c *cli.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
checked = true
|
checked = true
|
||||||
if result.Health == "true" || nresult.Health == true {
|
if result.Health == "true" || nresult.Health {
|
||||||
health = true
|
health = true
|
||||||
fmt.Printf("member %s is healthy: got healthy result from %s\n", m.ID, url)
|
fmt.Printf("member %s is healthy: got healthy result from %s\n", m.ID, url)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,18 +42,6 @@ var (
|
||||||
defaultDialTimeout = 30 * time.Second
|
defaultDialTimeout = 30 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// trimsplit slices s into all substrings separated by sep and returns a
|
|
||||||
// slice of the substrings between the separator with all leading and trailing
|
|
||||||
// white space removed, as defined by Unicode.
|
|
||||||
func trimsplit(s, sep string) []string {
|
|
||||||
raw := strings.Split(s, ",")
|
|
||||||
trimmed := make([]string, 0)
|
|
||||||
for _, r := range raw {
|
|
||||||
trimmed = append(trimmed, strings.TrimSpace(r))
|
|
||||||
}
|
|
||||||
return trimmed
|
|
||||||
}
|
|
||||||
|
|
||||||
func argOrStdin(args []string, stdin io.Reader, i int) (string, error) {
|
func argOrStdin(args []string, stdin io.Reader, i int) (string, error) {
|
||||||
if i < len(args) {
|
if i < len(args) {
|
||||||
return args[i], nil
|
return args[i], nil
|
||||||
|
|
|
@ -22,10 +22,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var memberPeerURLs string
|
||||||
memberID uint64
|
|
||||||
memberPeerURLs string
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewMemberCommand returns the cobra command for "member".
|
// NewMemberCommand returns the cobra command for "member".
|
||||||
func NewMemberCommand() *cobra.Command {
|
func NewMemberCommand() *cobra.Command {
|
||||||
|
|
|
@ -416,7 +416,7 @@ func TestCreateAndUpdateUser(t *testing.T) {
|
||||||
|
|
||||||
s := store{server: d, timeout: testTimeout, ensuredOnce: true, PasswordStore: fastPasswordStore{}}
|
s := store{server: d, timeout: testTimeout, ensuredOnce: true, PasswordStore: fastPasswordStore{}}
|
||||||
out, created, err := s.CreateOrUpdateUser(user)
|
out, created, err := s.CreateOrUpdateUser(user)
|
||||||
if created == false {
|
if !created {
|
||||||
t.Error("Should have created user, instead updated?")
|
t.Error("Should have created user, instead updated?")
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -427,7 +427,7 @@ func TestCreateAndUpdateUser(t *testing.T) {
|
||||||
t.Error("UpdateUser doesn't match given update. Got", out, "expected", expected)
|
t.Error("UpdateUser doesn't match given update. Got", out, "expected", expected)
|
||||||
}
|
}
|
||||||
out, created, err = s.CreateOrUpdateUser(update)
|
out, created, err = s.CreateOrUpdateUser(update)
|
||||||
if created == true {
|
if created {
|
||||||
t.Error("Should have updated user, instead created?")
|
t.Error("Should have updated user, instead created?")
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -572,6 +572,7 @@ func TestEnableAuth(t *testing.T) {
|
||||||
t.Error("Unexpected error", err)
|
t.Error("Unexpected error", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDisableAuth(t *testing.T) {
|
func TestDisableAuth(t *testing.T) {
|
||||||
trueval := "true"
|
trueval := "true"
|
||||||
falseval := "false"
|
falseval := "false"
|
||||||
|
|
|
@ -144,9 +144,7 @@ func (c *RaftCluster) PeerURLs() []string {
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
urls := make([]string, 0)
|
urls := make([]string, 0)
|
||||||
for _, p := range c.members {
|
for _, p := range c.members {
|
||||||
for _, addr := range p.PeerURLs {
|
urls = append(urls, p.PeerURLs...)
|
||||||
urls = append(urls, addr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sort.Strings(urls)
|
sort.Strings(urls)
|
||||||
return urls
|
return urls
|
||||||
|
@ -159,9 +157,7 @@ func (c *RaftCluster) ClientURLs() []string {
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
urls := make([]string, 0)
|
urls := make([]string, 0)
|
||||||
for _, p := range c.members {
|
for _, p := range c.members {
|
||||||
for _, url := range p.ClientURLs {
|
urls = append(urls, p.ClientURLs...)
|
||||||
urls = append(urls, url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sort.Strings(urls)
|
sort.Strings(urls)
|
||||||
return urls
|
return urls
|
||||||
|
|
|
@ -85,7 +85,7 @@ func (q *statsQueue) Rate() (float64, float64) {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if time.Now().Sub(back.SendingTime) > time.Second {
|
if time.Since(back.SendingTime) > time.Second {
|
||||||
q.Clear()
|
q.Clear()
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ func (ss *ServerStats) JSON() []byte {
|
||||||
ss.Lock()
|
ss.Lock()
|
||||||
stats := *ss
|
stats := *ss
|
||||||
ss.Unlock()
|
ss.Unlock()
|
||||||
stats.LeaderInfo.Uptime = time.Now().Sub(stats.LeaderInfo.StartTime).String()
|
stats.LeaderInfo.Uptime = time.Since(stats.LeaderInfo.StartTime).String()
|
||||||
stats.SendingPkgRate, stats.SendingBandwidthRate = stats.SendRates()
|
stats.SendingPkgRate, stats.SendingBandwidthRate = stats.SendRates()
|
||||||
stats.RecvingPkgRate, stats.RecvingBandwidthRate = stats.RecvRates()
|
stats.RecvingPkgRate, stats.RecvingBandwidthRate = stats.RecvRates()
|
||||||
b, err := json.Marshal(stats)
|
b, err := json.Marshal(stats)
|
||||||
|
|
|
@ -48,7 +48,7 @@ func CheckLeakedGoroutine() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
stackCount := make(map[string]int)
|
stackCount := make(map[string]int)
|
||||||
re := regexp.MustCompile("\\(0[0-9a-fx, ]*\\)")
|
re := regexp.MustCompile(`\(0[0-9a-fx, ]*\)`)
|
||||||
for _, g := range gs {
|
for _, g := range gs {
|
||||||
// strip out pointer arguments in first function of stack dump
|
// strip out pointer arguments in first function of stack dump
|
||||||
normalized := string(re.ReplaceAll([]byte(g), []byte("(...)")))
|
normalized := string(re.ReplaceAll([]byte(g), []byte("(...)")))
|
||||||
|
|
|
@ -289,7 +289,7 @@ func (s *store) Compact(rev int64) (<-chan struct{}, error) {
|
||||||
|
|
||||||
s.fifoSched.Schedule(j)
|
s.fifoSched.Schedule(j)
|
||||||
|
|
||||||
indexCompactionPauseDurations.Observe(float64(time.Now().Sub(start) / time.Millisecond))
|
indexCompactionPauseDurations.Observe(float64(time.Since(start) / time.Millisecond))
|
||||||
return ch, nil
|
return ch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
|
|
||||||
func (s *store) scheduleCompaction(compactMainRev int64, keep map[revision]struct{}) bool {
|
func (s *store) scheduleCompaction(compactMainRev int64, keep map[revision]struct{}) bool {
|
||||||
totalStart := time.Now()
|
totalStart := time.Now()
|
||||||
defer dbCompactionTotalDurations.Observe(float64(time.Now().Sub(totalStart) / time.Millisecond))
|
defer dbCompactionTotalDurations.Observe(float64(time.Since(totalStart) / time.Millisecond))
|
||||||
|
|
||||||
end := make([]byte, 8)
|
end := make([]byte, 8)
|
||||||
binary.BigEndian.PutUint64(end, uint64(compactMainRev+1))
|
binary.BigEndian.PutUint64(end, uint64(compactMainRev+1))
|
||||||
|
@ -54,7 +54,7 @@ func (s *store) scheduleCompaction(compactMainRev int64, keep map[revision]struc
|
||||||
// update last
|
// update last
|
||||||
revToBytes(revision{main: rev.main, sub: rev.sub + 1}, last)
|
revToBytes(revision{main: rev.main, sub: rev.sub + 1}, last)
|
||||||
tx.Unlock()
|
tx.Unlock()
|
||||||
dbCompactionPauseDurations.Observe(float64(time.Now().Sub(start) / time.Millisecond))
|
dbCompactionPauseDurations.Observe(float64(time.Since(start) / time.Millisecond))
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(100 * time.Millisecond):
|
case <-time.After(100 * time.Millisecond):
|
||||||
|
|
|
@ -117,10 +117,7 @@ func (eh *EventHistory) clone() *EventHistory {
|
||||||
Back: eh.Queue.Back,
|
Back: eh.Queue.Back,
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, e := range eh.Queue.Events {
|
copy(clonedQueue.Events, eh.Queue.Events)
|
||||||
clonedQueue.Events[i] = e
|
|
||||||
}
|
|
||||||
|
|
||||||
return &EventHistory{
|
return &EventHistory{
|
||||||
StartIndex: eh.StartIndex,
|
StartIndex: eh.StartIndex,
|
||||||
Queue: clonedQueue,
|
Queue: clonedQueue,
|
||||||
|
|
|
@ -345,7 +345,7 @@ func (s *store) Delete(nodePath string, dir, recursive bool) (*Event, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// recursive implies dir
|
// recursive implies dir
|
||||||
if recursive == true {
|
if recursive {
|
||||||
dir = true
|
dir = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue