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

View File

@ -10,46 +10,32 @@ import (
"os/exec" "os/exec"
"strings" "strings"
"github.com/spf13/cobra"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
abcicli "github.com/tendermint/abci/client" abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/counter" "github.com/tendermint/abci/example/counter"
"github.com/tendermint/abci/example/dummy" "github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server" "github.com/tendermint/abci/server"
"github.com/tendermint/abci/types" "github.com/tendermint/abci/types"
"github.com/tendermint/abci/version" "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 // client is a global variable so it can be reused by the console
var client abcicli.Client var (
client abcicli.Client
var logger log.Logger logger log.Logger
)
// flags // flags
var ( var (
// global // global
address string address string
abci string abci string
verbose bool verbose bool // for the println output
logLevel string // for the logger
// query // query
path string path string
@ -79,7 +65,11 @@ var RootCmd = &cobra.Command{
} }
if logger == nil { 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 { if client == nil {
var err error 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 { func Execute() error {
addGlobalFlags() addGlobalFlags()
addCommands() addCommands()
@ -103,9 +110,10 @@ func Execute() error {
} }
func addGlobalFlags() { 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().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().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() { func addQueryFlags() {

20
glide.lock generated
View File

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

View File

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

View File

@ -42,6 +42,7 @@ func (s *GRPCServer) OnStart() error {
if err != nil { if err != nil {
return err return err
} }
s.Logger.Info("Listening", "proto", s.proto, "addr", s.addr)
s.listener = ln s.listener = ln
s.server = grpc.NewServer() s.server = grpc.NewServer()
types.RegisterABCIApplicationServer(s.server, s.app) 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. # Change into that dir because we expect that.
cd "$DIR" cd "$DIR"
echo "RUN COUNTER OVER SOCKET"
# test golang counter # test golang counter
ABCI_APP="counter" go run ./*.go ABCI_APP="counter" go run ./*.go
echo "----------------------"
echo "RUN COUNTER OVER GRPC"
# test golang counter via grpc # test golang counter via grpc
ABCI_APP="counter --abci=grpc" ABCI="grpc" go run ./*.go ABCI_APP="counter --abci=grpc" ABCI="grpc" go run ./*.go
echo "----------------------"
# test nodejs counter # test nodejs counter
# TODO: fix node app # TODO: fix node app

View File

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