handle reconnect on first connect
This commit is contained in:
@@ -41,16 +41,17 @@ type PersistentConnection struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewPersistentConnection(address string) (*PersistentConnection, error) {
|
func NewPersistentConnection(address string) (*PersistentConnection, error) {
|
||||||
connection, err := net.Dial("tcp", address)
|
|
||||||
if err != nil {
|
p := &PersistentConnection{
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &PersistentConnection{
|
|
||||||
Conn: connection,
|
|
||||||
Died: make(chan bool, 1),
|
Died: make(chan bool, 1),
|
||||||
Dead: false,
|
Dead: false,
|
||||||
address: address,
|
address: address,
|
||||||
}, nil
|
}
|
||||||
|
err := p.Connect()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PersistentConnection) Connect() error {
|
func (m *PersistentConnection) Connect() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user