Move callbacks out of messageRouter (#269)

* move callbacks out of messageRouter

* OCD

* more OCD

* fix forwarder test

* even more OCD

* maximum OCD

* package name collision, copy lock by value
This commit is contained in:
David Colburn
2021-12-17 13:19:23 -08:00
committed by GitHub
parent a06edd885e
commit faa870de3d
82 changed files with 315 additions and 527 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ package selector
import (
"errors"
livekit "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit"
"github.com/livekit/livekit-server/pkg/config"
)
+1 -1
View File
@@ -1,7 +1,7 @@
package selector
import (
livekit "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit"
"github.com/thoas/go-funk"
)
+1 -1
View File
@@ -3,7 +3,7 @@ package selector
import (
"math"
livekit "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit"
"github.com/thoas/go-funk"
"github.com/livekit/livekit-server/pkg/config"
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"testing"
"time"
livekit "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
"github.com/stretchr/testify/require"
+1 -1
View File
@@ -1,7 +1,7 @@
package selector
import (
livekit "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit"
"github.com/thoas/go-funk"
)
+6 -6
View File
@@ -4,7 +4,7 @@ import (
"testing"
"time"
livekit "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit"
"github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/routing/selector"
@@ -31,22 +31,22 @@ var (
)
func TestSystemLoadSelector_SelectNode(t *testing.T) {
selector := selector.SystemLoadSelector{SysloadLimit: 1.0}
sel := selector.SystemLoadSelector{SysloadLimit: 1.0}
nodes := []*livekit.Node{}
_, err := selector.SelectNode(nodes)
var nodes []*livekit.Node
_, err := sel.SelectNode(nodes)
require.Error(t, err, "should error no available nodes")
// Select a node with high load when no nodes with low load are available
nodes = []*livekit.Node{nodeLoadHigh}
if _, err := selector.SelectNode(nodes); err != nil {
if _, err := sel.SelectNode(nodes); err != nil {
t.Error(err)
}
// Select a node with low load when available
nodes = []*livekit.Node{nodeLoadLow, nodeLoadHigh}
for i := 0; i < 5; i++ {
node, err := selector.SelectNode(nodes)
node, err := sel.SelectNode(nodes)
if err != nil {
t.Error(err)
}
+3 -2
View File
@@ -3,9 +3,10 @@ package selector
import (
"time"
"github.com/livekit/livekit-server/pkg/config"
livekit "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit"
"github.com/thoas/go-funk"
"github.com/livekit/livekit-server/pkg/config"
)
const AvailableSeconds = 5
+3 -2
View File
@@ -4,9 +4,10 @@ import (
"testing"
"time"
"github.com/livekit/livekit-server/pkg/routing/selector"
livekit "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/livekit"
"github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/routing/selector"
)
func TestIsAvailable(t *testing.T) {