Functional code for link

This commit is contained in:
Asim Aslam 2019-07-10 20:04:01 +01:00
parent e17ecf66b1
commit 998a23c963

View File

@ -44,8 +44,8 @@ type link struct {
func newLink(options options.Options) *link { func newLink(options options.Options) *link {
// default values // default values
var sock transport.Socket var sock transport.Socket
var addr string
id := "local" id := "local"
addr := "127.0.0.1:10001"
tr := transport.DefaultTransport tr := transport.DefaultTransport
lid, ok := options.Values().Get("link.id") lid, ok := options.Values().Get("link.id")
@ -144,14 +144,20 @@ func (l *link) Connect() error {
l.Unlock() l.Unlock()
return nil return nil
} }
defer l.Unlock()
// replace closed // replace closed
l.closed = make(chan bool) l.closed = make(chan bool)
// assume existing socket
if len(l.addr) == 0 {
go l.process()
return nil
}
// dial the endpoint // dial the endpoint
c, err := l.transport.Dial(l.addr) c, err := l.transport.Dial(l.addr)
if err != nil { if err != nil {
l.Unlock()
return nil return nil
} }