mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-01 23:51:21 +00:00
QuitService->BaseService
This commit is contained in:
parent
855255d73e
commit
161e36fd56
@ -19,7 +19,7 @@ const (
|
||||
)
|
||||
|
||||
type WSClient struct {
|
||||
QuitService
|
||||
BaseService
|
||||
Address string // IP:PORT or /path/to/socket
|
||||
Endpoint string // /websocket/url/endpoint
|
||||
Dialer func(string, string) (net.Conn, error)
|
||||
@ -39,7 +39,7 @@ func NewWSClient(remoteAddr, endpoint string) *WSClient {
|
||||
ResultsCh: make(chan json.RawMessage, wsResultsChannelCapacity),
|
||||
ErrorsCh: make(chan error, wsErrorsChannelCapacity),
|
||||
}
|
||||
wsClient.QuitService = *NewQuitService(log, "WSClient", wsClient)
|
||||
wsClient.BaseService = *NewBaseService(log, "WSClient", wsClient)
|
||||
return wsClient
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ func (wsc *WSClient) String() string {
|
||||
}
|
||||
|
||||
func (wsc *WSClient) OnStart() error {
|
||||
wsc.QuitService.OnStart()
|
||||
wsc.BaseService.OnStart()
|
||||
err := wsc.dial()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -84,7 +84,7 @@ func (wsc *WSClient) dial() error {
|
||||
}
|
||||
|
||||
func (wsc *WSClient) OnStop() {
|
||||
wsc.QuitService.OnStop()
|
||||
wsc.BaseService.OnStop()
|
||||
// ResultsCh/ErrorsCh is closed in receiveEventsRoutine.
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ const (
|
||||
// contains listener id, underlying ws connection,
|
||||
// and the event switch for subscribing to events
|
||||
type wsConnection struct {
|
||||
QuitService
|
||||
BaseService
|
||||
|
||||
remoteAddr string
|
||||
baseConn *websocket.Conn
|
||||
@ -285,13 +285,13 @@ func NewWSConnection(baseConn *websocket.Conn, funcMap map[string]*RPCFunc, evsw
|
||||
funcMap: funcMap,
|
||||
evsw: evsw,
|
||||
}
|
||||
wsc.QuitService = *NewQuitService(log, "wsConnection", wsc)
|
||||
wsc.BaseService = *NewBaseService(log, "wsConnection", wsc)
|
||||
return wsc
|
||||
}
|
||||
|
||||
// wsc.Start() blocks until the connection closes.
|
||||
func (wsc *wsConnection) OnStart() error {
|
||||
wsc.QuitService.OnStart()
|
||||
wsc.BaseService.OnStart()
|
||||
|
||||
// Read subscriptions/unsubscriptions to events
|
||||
go wsc.readRoutine()
|
||||
@ -318,7 +318,7 @@ func (wsc *wsConnection) OnStart() error {
|
||||
}
|
||||
|
||||
func (wsc *wsConnection) OnStop() {
|
||||
wsc.QuitService.OnStop()
|
||||
wsc.BaseService.OnStop()
|
||||
wsc.evsw.RemoveListener(wsc.remoteAddr)
|
||||
wsc.readTimeout.Stop()
|
||||
wsc.pingTicker.Stop()
|
||||
|
Loading…
x
Reference in New Issue
Block a user