Browse Source

NewXXXClient doesnt run Start or return error

pull/1780/head
Ethan Buchman 8 years ago
parent
commit
eda4f2dddc
9 changed files with 46 additions and 33 deletions
  1. +4
    -3
      client/client.go
  2. +2
    -3
      client/grpc_client.go
  3. +2
    -5
      client/socket_client.go
  4. +4
    -1
      cmd/abci-cli/abci-cli.go
  5. +2
    -2
      example/block_aware/block_aware_test.go
  6. +4
    -4
      example/dummy/dummy_test.go
  7. +2
    -2
      example/example_test.go
  8. +22
    -13
      glide.lock
  9. +4
    -0
      tests/test_app/app.go

+ 4
- 3
client/client.go View File

@ -43,15 +43,16 @@ type Client interface {
//----------------------------------------
// NewClient returns a new ABCI client of the specified transport type.
// It returns an error if the transport is not "socket" or "grpc"
func NewClient(addr, transport string, mustConnect bool) (client Client, err error) {
switch transport {
case "socket":
client, err = NewSocketClient(addr, mustConnect)
client = NewSocketClient(addr, mustConnect)
case "grpc":
client, err = NewGRPCClient(addr, mustConnect)
client = NewGRPCClient(addr, mustConnect)
default:
err = fmt.Errorf("Unknown abci transport %s", transport)
}
return
}


+ 2
- 3
client/grpc_client.go View File

@ -27,14 +27,13 @@ type grpcClient struct {
resCb func(*types.Request, *types.Response) // listens to all callbacks
}
func NewGRPCClient(addr string, mustConnect bool) (*grpcClient, error) {
func NewGRPCClient(addr string, mustConnect bool) *grpcClient {
cli := &grpcClient{
addr: addr,
mustConnect: mustConnect,
}
cli.BaseService = *cmn.NewBaseService(nil, "grpcClient", cli)
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
return cli, err
return cli
}
func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {


+ 2
- 5
client/socket_client.go View File

@ -42,7 +42,7 @@ type socketClient struct {
}
func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) {
func NewSocketClient(addr string, mustConnect bool) *socketClient {
cli := &socketClient{
reqQueue: make(chan *ReqRes, reqQueueSize),
flushTimer: cmn.NewThrottleTimer("socketClient", flushThrottleMS),
@ -53,10 +53,7 @@ func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) {
resCb: nil,
}
cli.BaseService = *cmn.NewBaseService(nil, "socketClient", cli)
// FIXME we are loosing "Starting socketClient" message here
// add logger to params?
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
return cli, err
return cli
}
func (cli *socketClient) OnStart() error {


+ 4
- 1
cmd/abci-cli/abci-cli.go View File

@ -139,7 +139,7 @@ func main() {
func before(c *cli.Context) error {
if logger == nil {
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
logger = log.NewFilter(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), log.AllowError())
}
if client == nil {
var err error
@ -149,6 +149,9 @@ func before(c *cli.Context) error {
os.Exit(1)
}
client.SetLogger(logger.With("module", "abci-client"))
if _, err := client.Start(); err != nil {
return err
}
}
return nil
}


+ 2
- 2
example/block_aware/block_aware_test.go View File

@ -23,8 +23,8 @@ func TestChainAware(t *testing.T) {
defer srv.Stop()
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
client := abcicli.NewSocketClient("unix://test.sock", false)
if _, err := client.Start(); err != nil {
t.Fatalf("Error starting socket client: %v", err.Error())
}
client.SetLogger(log.TestingLogger().With("module", "abci-client"))


+ 4
- 4
example/dummy/dummy_test.go View File

@ -221,8 +221,8 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
server.SetLogger(logger.With("module", "abci-server"))
// Connect to the socket
client, err := abcicli.NewSocketClient(socket, false)
if err != nil {
client := abcicli.NewSocketClient(socket, false)
if _, err := client.Start(); err != nil {
server.Stop()
return nil, nil, err
}
@ -244,8 +244,8 @@ func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, c
}
server.SetLogger(logger.With("module", "abci-server"))
client, err := abcicli.NewGRPCClient(socket, true)
if err != nil {
client := abcicli.NewGRPCClient(socket, true)
if _, err := client.Start(); err != nil {
server.Stop()
return nil, nil, err
}


+ 2
- 2
example/example_test.go View File

@ -46,8 +46,8 @@ func testStream(t *testing.T, app types.Application) {
defer server.Stop()
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
client := abcicli.NewSocketClient("unix://test.sock", false)
if _, err := client.Start(); err != nil {
t.Fatalf("Error starting socket client: %v", err.Error())
}
client.SetLogger(log.TestingLogger().With("module", "abci-client"))


+ 22
- 13
glide.lock View File

@ -1,12 +1,16 @@
hash: f9c2ddad16bf8652076a93bd9f398bb498eefb2f5bd2c89a77d966ebd12feec8
updated: 2017-05-05T14:57:21.118338652-04:00
updated: 2017-05-15T10:11:42.094564957-04:00
imports:
- name: github.com/btcsuite/btcd
version: 4b348c1d33373d672edd83fc576892d0e46686d2
version: b8df516b4b267acf2de46be593a9d948d1d2c420
subpackages:
- btcec
- name: github.com/btcsuite/fastsha256
version: 637e656429416087660c84436a2a035d69d54e2e
- name: github.com/clipperhouse/typewriter
version: c1a48da378ebb7db1db9f35981b5cc24bf2e5b85
- name: github.com/go-kit/kit
version: 0873e56b0faeae3a1d661b10d629135508ea5504
version: d67bb4c202e3b91377d1079b110a6c9ce23ab2f8
subpackages:
- log
- log/level
@ -14,7 +18,7 @@ imports:
- name: github.com/go-logfmt/logfmt
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
- name: github.com/go-stack/stack
version: 7a2f19628aabfe68f0766b59e74d6315f8347d22
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
- name: github.com/golang/protobuf
version: 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8
subpackages:
@ -27,7 +31,7 @@ imports:
- name: github.com/kr/logfmt
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
- name: github.com/pkg/errors
version: c605e284fe17294bda444b34710735b29d1a9d90
version: ff09b135c25aae272398c51a07235b90a75aa4f0
- name: github.com/syndtr/goleveldb
version: 8c81ea47d4c41a385645e133e15510fc6a2a74b4
subpackages:
@ -49,17 +53,17 @@ imports:
- edwards25519
- extra25519
- name: github.com/tendermint/go-crypto
version: 524ba917a3a1636f21ab2c0bf76b6526903ab879
version: a42b10e0feb465eb56fbc6bb5b71d57ef646ec57
- name: github.com/tendermint/go-wire
version: b53add0b622662731985485f3a19be7f684660b8
version: 301a758c9d28e9f3900ff5d545403cf4e5f6e73f
subpackages:
- data
- name: github.com/tendermint/merkleeyes
version: d0aa363fd4e015e509038c3a0ec493bc62ee0b8a
version: c722818b460381bc5b82e38c73ff6e22a9df624d
subpackages:
- iavl
- name: github.com/tendermint/tmlibs
version: d72136da0df105944199c9e04035147fc6a4befa
version: 812d9f9b84d1dfe4cb46ce021b3a2d97b48d1292
subpackages:
- common
- db
@ -67,9 +71,9 @@ imports:
- merkle
- process
- name: github.com/urfave/cli
version: ab403a54a148f2d857920810291539e1f817ee7b
version: d70f47eeca3afd795160003bc6e28b001d60c67c
- name: golang.org/x/crypto
version: 5a033cc77e57eca05bdb50522851d29e03569cbe
version: c7af5bf2638a1164f2eb5467c39c6cffbd13a02e
subpackages:
- nacl/secretbox
- openpgp/armor
@ -94,6 +98,11 @@ imports:
- transform
- unicode/bidi
- unicode/norm
- name: golang.org/x/tools
version: 144c6642b5d832d6c44a53dad6ee61665dd432ce
subpackages:
- go/ast/astutil
- imports
- name: google.golang.org/genproto
version: 411e09b969b1170a9f0c467558eb4c4c110d9c77
subpackages:
@ -116,7 +125,7 @@ imports:
- transport
testImports:
- name: github.com/davecgh/go-spew
version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
subpackages:
- spew
- name: github.com/pmezard/go-difflib
@ -124,7 +133,7 @@ testImports:
subpackages:
- difflib
- name: github.com/stretchr/testify
version: 4d4bfba8f1d1027c4fdbe371823030df51419987
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
subpackages:
- assert
- require

+ 4
- 0
tests/test_app/app.go View File

@ -36,8 +36,12 @@ func startClient(abciType string) abcicli.Client {
// Start client
client, err := abcicli.NewClient("tcp://127.0.0.1:46658", abciType, true)
if err != nil {
panic(err.Error())
}
if _, err := client.Start(); err != nil {
panic("connecting to abci_app: " + err.Error())
}
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
client.SetLogger(logger.With("module", "abcicli"))
return client


Loading…
Cancel
Save