mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
lessor: fix go vet, goword warnings, and unreliable test
This commit is contained in:
parent
016be1ef31
commit
ea21b8ee1f
@ -54,7 +54,7 @@ type RangeDeleter interface {
|
||||
DeleteRange(key, end []byte) (int64, int64)
|
||||
}
|
||||
|
||||
// A Lessor is the owner of leases. It can grant, revoke, renew and modify leases for lessee.
|
||||
// Lessor owns leases. It can grant, revoke, renew and modify leases for lessee.
|
||||
type Lessor interface {
|
||||
// SetRangeDeleter sets the RangeDeleter to the Lessor.
|
||||
// Lessor deletes the items in the revoked or expired lease from the
|
||||
@ -172,13 +172,13 @@ func (le *lessor) SetRangeDeleter(rd RangeDeleter) {
|
||||
le.rd = rd
|
||||
}
|
||||
|
||||
// TODO: when lessor is under high load, it should give out lease
|
||||
// with longer TTL to reduce renew load.
|
||||
func (le *lessor) Grant(id LeaseID, ttl int64) (*Lease, error) {
|
||||
if id == NoLease {
|
||||
return nil, ErrLeaseNotFound
|
||||
}
|
||||
|
||||
// TODO: when lessor is under high load, it should give out lease
|
||||
// with longer TTL to reduce renew load.
|
||||
l := &Lease{ID: id, TTL: ttl, itemSet: make(map[LeaseItem]struct{})}
|
||||
|
||||
le.mu.Lock()
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -96,7 +97,7 @@ func TestLessorRevoke(t *testing.T) {
|
||||
{"bar"},
|
||||
}
|
||||
|
||||
if err := le.Attach(l.ID, items); err != nil {
|
||||
if err = le.Attach(l.ID, items); err != nil {
|
||||
t.Fatalf("failed to attach items to the lease: %v", err)
|
||||
}
|
||||
|
||||
@ -108,7 +109,8 @@ func TestLessorRevoke(t *testing.T) {
|
||||
t.Errorf("got revoked lease %x", l.ID)
|
||||
}
|
||||
|
||||
wdeleted := []string{"foo_", "bar_"}
|
||||
wdeleted := []string{"bar_", "foo_"}
|
||||
sort.Sort(sort.StringSlice(fd.deleted))
|
||||
if !reflect.DeepEqual(fd.deleted, wdeleted) {
|
||||
t.Errorf("deleted= %v, want %v", fd.deleted, wdeleted)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user