fix grpc version; add log_level and some logging

This commit is contained in:
Ethan Buchman 2017-11-30 17:20:36 -05:00
parent 550d6a6081
commit 10031f57d5
7 changed files with 60 additions and 41 deletions

View File

@ -60,6 +60,7 @@ RETRY_LOOP:
continue RETRY_LOOP
}
cli.Logger.Info("Dialed server. Waiting for echo.", "addr", cli.addr)
client := types.NewABCIApplicationClient(conn)
ENSURE_CONNECTED:
@ -68,6 +69,7 @@ RETRY_LOOP:
if err == nil {
break ENSURE_CONNECTED
}
cli.Logger.Info("Echo failed", "err", err)
time.Sleep(time.Second * echoRetryIntervalSeconds)
}

View File

@ -10,46 +10,32 @@ import (
"os/exec"
"strings"
"github.com/spf13/cobra"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/counter"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
"github.com/tendermint/abci/version"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
"github.com/spf13/cobra"
)
// Structure for data passed to print response.
type response struct {
// generic abci response
Data []byte
Code uint32
Log string
Query *queryResponse
}
type queryResponse struct {
Key []byte
Value []byte
Height uint64
Proof []byte
}
// client is a global variable so it can be reused by the console
var client abcicli.Client
var logger log.Logger
var (
client abcicli.Client
logger log.Logger
)
// flags
var (
// global
address string
abci string
verbose bool
address string
abci string
verbose bool // for the println output
logLevel string // for the logger
// query
path string
@ -79,7 +65,11 @@ var RootCmd = &cobra.Command{
}
if logger == nil {
logger = log.NewFilter(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), log.AllowError())
allowLevel, err := log.AllowLevel(logLevel)
if err != nil {
return err
}
logger = log.NewFilter(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), allowLevel)
}
if client == nil {
var err error
@ -96,6 +86,23 @@ var RootCmd = &cobra.Command{
},
}
// Structure for data passed to print response.
type response struct {
// generic abci response
Data []byte
Code uint32
Log string
Query *queryResponse
}
type queryResponse struct {
Key []byte
Value []byte
Height uint64
Proof []byte
}
func Execute() error {
addGlobalFlags()
addCommands()
@ -103,9 +110,10 @@ func Execute() error {
}
func addGlobalFlags() {
RootCmd.PersistentFlags().StringVarP(&address, "address", "", "tcp://127.0.0.1:46658", "Address of application socket")
RootCmd.PersistentFlags().StringVarP(&address, "address", "", "tcp://0.0.0.0:46658", "Address of application socket")
RootCmd.PersistentFlags().StringVarP(&abci, "abci", "", "socket", "Either socket or grpc")
RootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Print the command and results as if it were a console session")
RootCmd.PersistentFlags().StringVarP(&logLevel, "log_level", "", "debug", "Set the logger level")
}
func addQueryFlags() {

20
glide.lock generated
View File

@ -1,8 +1,8 @@
hash: 971ad090f3190ffd759deecf118a0eaefe7eceb4b1a8057800e332712fc1a7c2
updated: 2017-11-30T15:29:31.740172292-05:00
hash: 6cb2c869c8ce7d9e43b1e8930b9b1bc974ebb3d36d4b704fc78b77efba956a13
updated: 2017-11-30T17:08:29.176515576-05:00
imports:
- name: github.com/btcsuite/btcd
version: 8cea3866d0f7fb12d567a20744942c0d078c7d15
version: 2e60448ffcc6bf78332d1fe590260095f554dd78
subpackages:
- btcec
- name: github.com/go-kit/kit
@ -44,7 +44,7 @@ imports:
- name: github.com/kr/logfmt
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
- name: github.com/pkg/errors
version: 645ef00459ed84a119197bfb8d8205042c6df63d
version: f15c970de5b76fac0b59abb32d62c17cc7bed265
- name: github.com/spf13/cobra
version: 7b2c5ac9fc04fc5efafb60700713d4fa609b777b
- name: github.com/spf13/pflag
@ -72,7 +72,7 @@ imports:
- name: github.com/tendermint/go-crypto
version: b4f04f196cd719660e43b91202cd60d9a95b1837
- name: github.com/tendermint/go-wire
version: 3f073b1a9c841d9b88d03ca8181f61278188adca
version: 5ab49b4c6ad674da6b81442911cf713ef0afb544
subpackages:
- data
- name: github.com/tendermint/iavl
@ -85,7 +85,7 @@ imports:
- log
- process
- name: golang.org/x/crypto
version: 9f005a07e0d31d45e6656d241bb5c0f2efd4bc94
version: 94eea52f7b742c7cbe0b03b22f0c4c8631ece122
subpackages:
- nacl/secretbox
- openpgp/armor
@ -94,7 +94,7 @@ imports:
- ripemd160
- salsa20/salsa
- name: golang.org/x/net
version: 9dfe39835686865bff950a07b394c12a98ddc811
version: a8b9294777976932365dabb6640cf1468d95c70f
subpackages:
- context
- http2
@ -104,18 +104,18 @@ imports:
- lex/httplex
- trace
- name: golang.org/x/text
version: 88f656faf3f37f690df1a32515b479415e1a6769
version: 75cc3cad82b5f47d3fb229ddda8c5167da14f294
subpackages:
- secure/bidirule
- transform
- unicode/bidi
- unicode/norm
- name: google.golang.org/genproto
version: 891aceb7c239e72692819142dfca057bdcbfcb96
version: 7f0da29060c682909f650ad8ed4e515bd74fa12a
subpackages:
- googleapis/rpc/status
- name: google.golang.org/grpc
version: f7bf885db0b7479a537ec317c6e48ce53145f3db
version: 401e0e00e4bb830a10496d64cd95e068c5bf50de
subpackages:
- balancer
- codes

View File

@ -1,13 +1,15 @@
package: github.com/tendermint/abci
import:
- package: github.com/gogo/protobuf
version: v0.5
subpackages:
- proto
- package: github.com/spf13/cobra
version: v0.0.1
- package: github.com/tendermint/go-crypto
version: develop
- package: github.com/tendermint/go-wire
version: data-bytes-marshal-unmarshal
version: develop
subpackages:
- data
- package: github.com/tendermint/iavl
@ -23,6 +25,7 @@ import:
subpackages:
- context
- package: google.golang.org/grpc
version: v1.7.3
testImport:
- package: github.com/stretchr/testify
subpackages:

View File

@ -42,6 +42,7 @@ func (s *GRPCServer) OnStart() error {
if err != nil {
return err
}
s.Logger.Info("Listening", "proto", s.proto, "addr", s.addr)
s.listener = ln
s.server = grpc.NewServer()
types.RegisterABCIApplicationServer(s.server, s.app)

View File

@ -11,11 +11,16 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# Change into that dir because we expect that.
cd "$DIR"
echo "RUN COUNTER OVER SOCKET"
# test golang counter
ABCI_APP="counter" go run ./*.go
echo "----------------------"
echo "RUN COUNTER OVER GRPC"
# test golang counter via grpc
ABCI_APP="counter --abci=grpc" ABCI="grpc" go run ./*.go
echo "----------------------"
# test nodejs counter
# TODO: fix node app

View File

@ -17,7 +17,7 @@ function testExample() {
echo "Example $N: $APP"
$APP &> /dev/null &
sleep 2
abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new"
abci-cli --log_level=error --verbose batch < "$INPUT" > "${INPUT}.out.new"
killall "$3"
pre=$(shasum < "${INPUT}.out")