Skip to content

Commit

Permalink
Merge pull request #8500 from heyitsanthony/clientv3-spelling
Browse files Browse the repository at this point in the history
clientv3: goword spelling check
  • Loading branch information
Anthony Romano committed Sep 7, 2017
2 parents ec36d00 + 2d0eec0 commit 9c3474e
Show file tree
Hide file tree
Showing 30 changed files with 167 additions and 150 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ addons:
sources:
- debian-sid
packages:
- libpcap-dev
- libaspell-dev
- libhunspell-dev
- hunspell-en-us
- aspell-en
- shellcheck

before_install:
- go get -v -u github.com/chzchzchz/goword
- go get -v -u -tags spell github.com/chzchzchz/goword
- go get -v -u github.com/coreos/license-bill-of-materials
- go get -v -u honnef.co/go/tools/cmd/gosimple
- go get -v -u honnef.co/go/tools/cmd/unused
Expand Down
24 changes: 24 additions & 0 deletions .words
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
RPC
RPCs
cancelable
cancelation
defragment
defragmenting
etcd
gRPC
goroutine
goroutines
iff
inflight
keepalive
keepalives
keyspace
linearization
localhost
mutex
prefetching
protobuf
serializable
teardown
uncontended
unprefixed
14 changes: 7 additions & 7 deletions clientv3/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type simpleBalancer struct {
readyc chan struct{}
readyOnce sync.Once

// mu protects upEps, pinAddr, and connectingAddr
// mu protects all fields below.
mu sync.RWMutex

// upc closes when upEps transitions from empty to non-zero or the balancer closes.
// upc closes when pinAddr transitions from empty to non-empty or the balancer closes.
upc chan struct{}

// downc closes when grpc calls down() on pinAddr
Expand All @@ -65,7 +65,7 @@ type simpleBalancer struct {
host2ep map[string]string

// pinAddr is the currently pinned address; set to the empty string on
// intialization and shutdown.
// initialization and shutdown.
pinAddr string

closed bool
Expand Down Expand Up @@ -234,8 +234,8 @@ func (b *simpleBalancer) Up(addr grpc.Address) func(error) {
defer b.mu.Unlock()

// gRPC might call Up after it called Close. We add this check
// to "fix" it up at application layer. Or our simplerBalancer
// might panic since b.upc is closed.
// to "fix" it up at application layer. Otherwise, will panic
// if b.upc is already closed.
if b.closed {
return func(err error) {}
}
Expand Down Expand Up @@ -327,8 +327,8 @@ func (b *simpleBalancer) Close() error {

// In the case of following scenario:
// 1. upc is not closed; no pinned address
// 2. client issues an rpc, calling invoke(), which calls Get(), enters for loop, blocks
// 3. clientconn.Close() calls balancer.Close(); closed = true
// 2. client issues an RPC, calling invoke(), which calls Get(), enters for loop, blocks
// 3. client.conn.Close() calls balancer.Close(); closed = true
// 4. for loop in Get() never exits since ctx is the context passed in by the client and may not be canceled
// we must close upc so Get() exits from blocking on upc
select {
Expand Down
13 changes: 5 additions & 8 deletions clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ type Client struct {
ctx context.Context
cancel context.CancelFunc

// Username is a username for authentication
// Username is a user name for authentication.
Username string
// Password is a password for authentication
// Password is a password for authentication.
Password string
// tokenCred is an instance of WithPerRPCCredentials()'s argument
tokenCred *authTokenCredential
Expand Down Expand Up @@ -216,11 +216,8 @@ func (c *Client) dialSetupOpts(endpoint string, dopts ...grpc.DialOption) (opts
}
if c.cfg.DialKeepAliveTime > 0 {
params := keepalive.ClientParameters{
Time: c.cfg.DialKeepAliveTime,
}
// Only relevant when KeepAliveTime is non-zero
if c.cfg.DialKeepAliveTimeout > 0 {
params.Timeout = c.cfg.DialKeepAliveTimeout
Time: c.cfg.DialKeepAliveTime,
Timeout: c.cfg.DialKeepAliveTimeout,
}
opts = append(opts, grpc.WithKeepaliveParams(params))
}
Expand Down Expand Up @@ -377,7 +374,7 @@ func newClient(cfg *Config) (*Client, error) {

client.balancer = newSimpleBalancer(cfg.Endpoints)
// use Endpoints[0] so that for https:// without any tls config given, then
// grpc will assume the ServerName is in the endpoint.
// grpc will assume the certificate server name is the endpoint host.
conn, err := client.dial(cfg.Endpoints[0], grpc.WithBalancer(client.balancer))
if err != nil {
client.cancel()
Expand Down
4 changes: 2 additions & 2 deletions clientv3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestDialCancel(t *testing.T) {
t.Fatal(err)
}

// connect to ipv4 blackhole so dial blocks
// connect to ipv4 black hole so dial blocks
c.SetEndpoints("http://254.0.0.1:12345")

// issue Get to force redial attempts
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestDialTimeout(t *testing.T) {
for i, cfg := range testCfgs {
donec := make(chan error)
go func() {
// without timeout, dial continues forever on ipv4 blackhole
// without timeout, dial continues forever on ipv4 black hole
c, err := New(cfg)
if c != nil || err == nil {
t.Errorf("#%d: new client should fail", i)
Expand Down
2 changes: 1 addition & 1 deletion clientv3/clientv3util/example_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ExampleKeyExists_put() {
kvc := clientv3.NewKV(cli)

// perform a put only if key is missing
// It is useful to do the check (transactionally) to avoid overwriting
// It is useful to do the check atomically to avoid overwriting
// the existing key which would generate potentially unwanted events,
// unless of course you wanted to do an overwrite no matter what.
_, err = kvc.Txn(context.Background()).
Expand Down
6 changes: 2 additions & 4 deletions clientv3/compact_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ func (op CompactOp) toRequest() *pb.CompactionRequest {
return &pb.CompactionRequest{Revision: op.revision, Physical: op.physical}
}

// WithCompactPhysical makes compact RPC call wait until
// the compaction is physically applied to the local database
// such that compacted entries are totally removed from the
// backend database.
// WithCompactPhysical makes Compact wait until all compacted entries are
// removed from the etcd server's storage.
func WithCompactPhysical() CompactOption {
return func(op *CompactOp) { op.physical = true }
}
4 changes: 2 additions & 2 deletions clientv3/concurrency/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ func (e *Election) observe(ctx context.Context, ch chan<- v3.GetResponse) {
cancel()
return
}
// only accept PUTs; a DELETE will make observe() spin
// only accept puts; a delete will make observe() spin
for _, ev := range wr.Events {
if ev.Type == mvccpb.PUT {
hdr, kv = &wr.Header, ev.Kv
// may have multiple revs; hdr.rev = the last rev
// set to kv's rev in case batch has multiple PUTs
// set to kv's rev in case batch has multiple Puts
hdr.Revision = kv.ModRevision
break
}
Expand Down
2 changes: 1 addition & 1 deletion clientv3/concurrency/example_stm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func ExampleSTM_apply() {
xfer := fromInt / 2
fromInt, toInt = fromInt-xfer, toInt+xfer

// writeback
// write back
stm.Put(fromK, fmt.Sprintf("%d", fromInt))
stm.Put(toK, fmt.Sprintf("%d", toInt))
return nil
Expand Down
2 changes: 1 addition & 1 deletion clientv3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Config struct {
// TLS holds the client secure credentials, if any.
TLS *tls.Config

// Username is a username for authentication.
// Username is a user name for authentication.
Username string `json:"username"`

// Password is a password for authentication.
Expand Down
2 changes: 1 addition & 1 deletion clientv3/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// Make sure to close the client after using it. If the client is not closed, the
// connection will have leaky goroutines.
//
// To specify client request timeout, pass context.WithTimeout to APIs:
// To specify a client request timeout, wrap the context with context.WithTimeout:
//
// ctx, cancel := context.WithTimeout(context.Background(), timeout)
// resp, err := kvc.Put(ctx, "sample_key", "sample_value")
Expand Down
7 changes: 5 additions & 2 deletions clientv3/example_kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ func ExampleKV_txn() {

ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
_, err = kvc.Txn(ctx).
If(clientv3.Compare(clientv3.Value("key"), ">", "abc")). // txn value comparisons are lexical
Then(clientv3.OpPut("key", "XYZ")). // this runs, since 'xyz' > 'abc'
// txn value comparisons are lexical
If(clientv3.Compare(clientv3.Value("key"), ">", "abc")).
// the "Then" runs, since "xyz" > "abc"
Then(clientv3.OpPut("key", "XYZ")).
// the "Else" does not run
Else(clientv3.OpPut("key", "ABC")).
Commit()
cancel()
Expand Down
15 changes: 5 additions & 10 deletions clientv3/example_maintenence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,15 @@ func ExampleMaintenance_status() {
}
defer cli.Close()

// resp, err := cli.Status(context.Background(), ep)
//
// or
//
mapi := clientv3.NewMaintenance(cli)
resp, err := mapi.Status(context.Background(), ep)
resp, err := cli.Status(context.Background(), ep)
if err != nil {
log.Fatal(err)
}
fmt.Printf("endpoint: %s / IsLeader: %v\n", ep, resp.Header.MemberId == resp.Leader)
fmt.Printf("endpoint: %s / Leader: %v\n", ep, resp.Header.MemberId == resp.Leader)
}
// endpoint: localhost:2379 / IsLeader: false
// endpoint: localhost:22379 / IsLeader: false
// endpoint: localhost:32379 / IsLeader: true
// endpoint: localhost:2379 / Leader: false
// endpoint: localhost:22379 / Leader: false
// endpoint: localhost:32379 / Leader: true
}

func ExampleMaintenance_defragment() {
Expand Down
5 changes: 3 additions & 2 deletions clientv3/example_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func ExampleClient_metrics() {
}
defer cli.Close()

// get a key so it shows up in the metrics as a range rpc
// get a key so it shows up in the metrics as a range RPC
cli.Get(context.TODO(), "test_key")

// listen for all prometheus metrics
Expand Down Expand Up @@ -80,5 +80,6 @@ func ExampleClient_metrics() {
break
}
}
// Output: grpc_client_started_total{grpc_method="Range",grpc_service="etcdserverpb.KV",grpc_type="unary"} 1
// Output:
// grpc_client_started_total{grpc_method="Range",grpc_service="etcdserverpb.KV",grpc_type="unary"} 1
}
9 changes: 5 additions & 4 deletions clientv3/integration/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestDialTLSExpired(t *testing.T) {
if err != nil {
t.Fatal(err)
}
// expect remote errors 'tls: bad certificate'
// expect remote errors "tls: bad certificate"
_, err = clientv3.New(clientv3.Config{
Endpoints: []string{clus.Members[0].GRPCAddr()},
DialTimeout: 3 * time.Second,
Expand All @@ -72,7 +72,7 @@ func TestDialTLSNoConfig(t *testing.T) {
defer testutil.AfterTest(t)
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1, ClientTLS: &testTLSInfo})
defer clus.Terminate(t)
// expect 'signed by unknown authority'
// expect "signed by unknown authority"
_, err := clientv3.New(clientv3.Config{
Endpoints: []string{clus.Members[0].GRPCAddr()},
DialTimeout: time.Second,
Expand All @@ -82,7 +82,8 @@ func TestDialTLSNoConfig(t *testing.T) {
}
}

// TestDialSetEndpoints ensures SetEndpoints can replace unavailable endpoints with available ones.
// TestDialSetEndpointsBeforeFail ensures SetEndpoints can replace unavailable
// endpoints with available ones.
func TestDialSetEndpointsBeforeFail(t *testing.T) {
testDialSetEndpoints(t, true)
}
Expand Down Expand Up @@ -190,7 +191,7 @@ func TestDialForeignEndpoint(t *testing.T) {
}
}

// TestSetEndpointAndPut checks that a Put following a SetEndpoint
// TestSetEndpointAndPut checks that a Put following a SetEndpoints
// to a working endpoint will always succeed.
func TestSetEndpointAndPut(t *testing.T) {
defer testutil.AfterTest(t)
Expand Down
4 changes: 2 additions & 2 deletions clientv3/integration/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,8 @@ func TestKVPutStoppedServerAndClose(t *testing.T) {
}
}

// TestKVGetOneEndpointDown ensures a client can connect and get if one endpoint is down
func TestKVPutOneEndpointDown(t *testing.T) {
// TestKVGetOneEndpointDown ensures a client can connect and get if one endpoint is down.
func TestKVGetOneEndpointDown(t *testing.T) {
defer testutil.AfterTest(t)
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
defer clus.Terminate(t)
Expand Down
17 changes: 7 additions & 10 deletions clientv3/integration/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ type leaseCh struct {
ch <-chan *clientv3.LeaseKeepAliveResponse
}

// TestLeaseKeepAliveNotFound ensures a revoked lease won't stop other keep alives
// TestLeaseKeepAliveNotFound ensures a revoked lease won't halt other leases.
func TestLeaseKeepAliveNotFound(t *testing.T) {
defer testutil.AfterTest(t)

Expand Down Expand Up @@ -288,9 +288,7 @@ func TestLeaseGrantErrConnClosed(t *testing.T) {
_, err := cli.Grant(context.TODO(), 5)
if err != nil && err != grpc.ErrClientConnClosing && err != context.Canceled {
// grpc.ErrClientConnClosing if grpc-go balancer calls 'Get' after client.Close.
// context.Canceled if grpc-go balancer calls 'Get' with inflight client.Close,
// soon transportMonitor selects on ClientTransport.Error() and resetTransport(false)
// that cancels the context and closes the transport.
// context.Canceled if grpc-go balancer calls 'Get' with an inflight client.Close.
t.Fatalf("expected %v or %v, got %v", grpc.ErrClientConnClosing, context.Canceled, err)
}
}()
Expand Down Expand Up @@ -364,7 +362,7 @@ func TestLeaseRevokeNewAfterClose(t *testing.T) {
}
}

// TestLeaseKeepAliveCloseAfterDisconnectExpire ensures the keep alive channel is closed
// TestLeaseKeepAliveCloseAfterDisconnectRevoke ensures the keep alive channel is closed
// following a disconnection, lease revoke, then reconnect.
func TestLeaseKeepAliveCloseAfterDisconnectRevoke(t *testing.T) {
defer testutil.AfterTest(t)
Expand Down Expand Up @@ -399,7 +397,7 @@ func TestLeaseKeepAliveCloseAfterDisconnectRevoke(t *testing.T) {

clus.Members[0].Restart(t)

// some keep-alives may still be buffered; drain until close
// some responses may still be buffered; drain until close
timer := time.After(time.Duration(kresp.TTL) * time.Second)
for kresp != nil {
select {
Expand Down Expand Up @@ -555,8 +553,7 @@ func TestLeaseTimeToLiveLeaseNotFound(t *testing.T) {
}

lresp, err := cli.TimeToLive(context.Background(), resp.ID)
// TimeToLive() doesn't return LeaseNotFound error
// but return a response with TTL to be -1
// TimeToLive() should return a response with TTL=-1.
if err != nil {
t.Fatalf("expected err to be nil")
}
Expand Down Expand Up @@ -677,8 +674,8 @@ func TestLeaseKeepAliveLoopExit(t *testing.T) {
}
}

// TestV3LeaseFailureOverlap issues Grant and Keepalive requests to a cluster
// before, during, and after quorum loss to confirm Grant/Keepalive tolerates
// TestV3LeaseFailureOverlap issues Grant and KeepAlive requests to a cluster
// before, during, and after quorum loss to confirm Grant/KeepAlive tolerates
// transient cluster failure.
func TestV3LeaseFailureOverlap(t *testing.T) {
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 2})
Expand Down
Loading

0 comments on commit 9c3474e

Please sign in to comment.