Compare commits

...

1 commit

Author SHA1 Message Date
Bohdan Horbeshko e55463fc98 Fix passing Component to StreamManager
0a4acd12c3, which fixes #160, introduced
a regression as it assumed only Client may implement StreamClient, and
passing a component triggers an unconditional "client is not
disconnected" error.
2021-12-18 10:55:35 -05:00

View file

@ -114,10 +114,16 @@ func (sm *StreamManager) Stop() {
func (sm *StreamManager) connect() error {
if sm.client != nil {
if c, ok := sm.client.(*Client); ok {
if c.CurrentState.getState() == StateDisconnected {
var scs *SyncConnState
if client, ok := sm.client.(*Client); ok {
scs = &client.CurrentState
}
if component, ok := sm.client.(*Component); ok {
scs = &component.CurrentState
}
if scs != nil && scs.getState() == StateDisconnected {
sm.Metrics = initMetrics()
err := c.Connect()
err := sm.client.Connect()
if err != nil {
return err
}
@ -127,7 +133,6 @@ func (sm *StreamManager) connect() error {
return nil
}
}
}
return errors.New("client is not disconnected")
}