Add further link comments
This commit is contained in:
parent
8c157c1d5f
commit
4cca2b43a3
@ -92,8 +92,7 @@ func newLink(options options.Options) *link {
|
|||||||
|
|
||||||
// link methods
|
// link methods
|
||||||
|
|
||||||
// process processes messages on the send queue.
|
// process processes messages on the send and receive queues.
|
||||||
// these are messages to be sent to the remote side.
|
|
||||||
func (l *link) process() {
|
func (l *link) process() {
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@ -138,6 +137,7 @@ func (l *link) recv(m *transport.Message) error {
|
|||||||
return l.socket.Recv(m)
|
return l.socket.Recv(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connect attempts to connect to an address and sets the socket
|
||||||
func (l *link) Connect() error {
|
func (l *link) Connect() error {
|
||||||
l.Lock()
|
l.Lock()
|
||||||
if l.connected {
|
if l.connected {
|
||||||
@ -185,24 +185,28 @@ func (l *link) Id() string {
|
|||||||
return l.id
|
return l.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the remote ip of the link
|
||||||
func (l *link) Remote() string {
|
func (l *link) Remote() string {
|
||||||
l.RLock()
|
l.RLock()
|
||||||
defer l.RUnlock()
|
defer l.RUnlock()
|
||||||
return l.socket.Remote()
|
return l.socket.Remote()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the local ip of the link
|
||||||
func (l *link) Local() string {
|
func (l *link) Local() string {
|
||||||
l.RLock()
|
l.RLock()
|
||||||
defer l.RUnlock()
|
defer l.RUnlock()
|
||||||
return l.socket.Local()
|
return l.socket.Local()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// length/rate of the link
|
||||||
func (l *link) Length() int {
|
func (l *link) Length() int {
|
||||||
l.RLock()
|
l.RLock()
|
||||||
defer l.RUnlock()
|
defer l.RUnlock()
|
||||||
return l.length
|
return l.length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// weight checks the size of the queues
|
||||||
func (l *link) Weight() int {
|
func (l *link) Weight() int {
|
||||||
return len(l.sendQueue) + len(l.recvQueue)
|
return len(l.sendQueue) + len(l.recvQueue)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user