|
@ -11,7 +11,7 @@ import ( |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
"github.com/tendermint/abci/types" |
|
|
"github.com/tendermint/abci/types" |
|
|
common "github.com/tendermint/go-common" |
|
|
|
|
|
|
|
|
cmn "github.com/tendermint/go-common" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const ( |
|
|
const ( |
|
@ -27,10 +27,10 @@ const flushThrottleMS = 20 // Don't wait longer than... |
|
|
// the application in general is not meant to be interfaced
|
|
|
// the application in general is not meant to be interfaced
|
|
|
// with concurrent callers.
|
|
|
// with concurrent callers.
|
|
|
type socketClient struct { |
|
|
type socketClient struct { |
|
|
common.BaseService |
|
|
|
|
|
|
|
|
cmn.BaseService |
|
|
|
|
|
|
|
|
reqQueue chan *ReqRes |
|
|
reqQueue chan *ReqRes |
|
|
flushTimer *common.ThrottleTimer |
|
|
|
|
|
|
|
|
flushTimer *cmn.ThrottleTimer |
|
|
mustConnect bool |
|
|
mustConnect bool |
|
|
|
|
|
|
|
|
mtx sync.Mutex |
|
|
mtx sync.Mutex |
|
@ -45,14 +45,14 @@ type socketClient struct { |
|
|
func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) { |
|
|
func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) { |
|
|
cli := &socketClient{ |
|
|
cli := &socketClient{ |
|
|
reqQueue: make(chan *ReqRes, reqQueueSize), |
|
|
reqQueue: make(chan *ReqRes, reqQueueSize), |
|
|
flushTimer: common.NewThrottleTimer("socketClient", flushThrottleMS), |
|
|
|
|
|
|
|
|
flushTimer: cmn.NewThrottleTimer("socketClient", flushThrottleMS), |
|
|
mustConnect: mustConnect, |
|
|
mustConnect: mustConnect, |
|
|
|
|
|
|
|
|
addr: addr, |
|
|
addr: addr, |
|
|
reqSent: list.New(), |
|
|
reqSent: list.New(), |
|
|
resCb: nil, |
|
|
resCb: nil, |
|
|
} |
|
|
} |
|
|
cli.BaseService = *common.NewBaseService(nil, "socketClient", cli) |
|
|
|
|
|
|
|
|
cli.BaseService = *cmn.NewBaseService(nil, "socketClient", cli) |
|
|
|
|
|
|
|
|
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
|
|
|
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
|
|
|
return cli, err |
|
|
return cli, err |
|
@ -65,7 +65,7 @@ func (cli *socketClient) OnStart() error { |
|
|
var conn net.Conn |
|
|
var conn net.Conn |
|
|
RETRY_LOOP: |
|
|
RETRY_LOOP: |
|
|
for { |
|
|
for { |
|
|
conn, err = common.Connect(cli.addr) |
|
|
|
|
|
|
|
|
conn, err = cmn.Connect(cli.addr) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
if cli.mustConnect { |
|
|
if cli.mustConnect { |
|
|
return err |
|
|
return err |
|
|