From 4fddd69229e30f5c693606a2e31bfbf61e0bfbb0 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 22 Oct 2019 16:50:00 +0100 Subject: [PATCH 1/3] Add placeholders for link metrics --- tunnel/link.go | 15 +++++++++++++++ tunnel/tunnel.go | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/tunnel/link.go b/tunnel/link.go index 181121e7..580c6abd 100644 --- a/tunnel/link.go +++ b/tunnel/link.go @@ -85,6 +85,21 @@ func (l *link) expiry() { } } +// Delay is the current load on the link +func (l *link) Delay() int64 { + return 0 +} + +// Transfer rate capability as bits per second (higher is better) +func (l *link) Rate() float64 { + return float64(10e8) +} + +// Length returns the roundtrip time as nanoseconds (lower is better) +func (l *link) Length() int64 { + return time.Second.Nanoseconds() +} + func (l *link) Id() string { l.RLock() defer l.RUnlock() diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index a2671f62..cc03f07f 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -59,6 +59,12 @@ type Link interface { Id() string // Status of the link e.g connected/closed Status() string + // Delay is the current load on the link + Delay() int64 + // Transfer rate capability as bits per second (higher is better) + Rate() float64 + // Length returns the roundtrip time as nanoseconds (lower is better) + Length() int64 // honours transport socket transport.Socket } From ab9fa20a50d145ee763084cadf5bc9c188771328 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 22 Oct 2019 16:53:47 +0100 Subject: [PATCH 2/3] Update comments --- tunnel/link.go | 2 +- tunnel/tunnel.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tunnel/link.go b/tunnel/link.go index 580c6abd..22362198 100644 --- a/tunnel/link.go +++ b/tunnel/link.go @@ -90,7 +90,7 @@ func (l *link) Delay() int64 { return 0 } -// Transfer rate capability as bits per second (higher is better) +// Current transfer rate as bits per second (lower is better) func (l *link) Rate() float64 { return float64(10e8) } diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index cc03f07f..9a52ffaf 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -59,9 +59,9 @@ type Link interface { Id() string // Status of the link e.g connected/closed Status() string - // Delay is the current load on the link + // Delay is the current load on the link (lower is better) Delay() int64 - // Transfer rate capability as bits per second (higher is better) + // Current transfer rate as bits per second (lower is better) Rate() float64 // Length returns the roundtrip time as nanoseconds (lower is better) Length() int64 From 85e273afa541937975e66c7e34546dc1f6e9cc7a Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 22 Oct 2019 17:02:22 +0100 Subject: [PATCH 3/3] reorder methods --- tunnel/tunnel.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 9a52ffaf..73c937f3 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -57,14 +57,14 @@ type Tunnel interface { type Link interface { // The id of the link Id() string - // Status of the link e.g connected/closed - Status() string // Delay is the current load on the link (lower is better) Delay() int64 - // Current transfer rate as bits per second (lower is better) - Rate() float64 // Length returns the roundtrip time as nanoseconds (lower is better) Length() int64 + // Current transfer rate as bits per second (lower is better) + Rate() float64 + // Status of the link e.g connected/closed + Status() string // honours transport socket transport.Socket }