aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go32
1 files changed, 21 insertions, 11 deletions
diff --git a/config.go b/config.go
index a286386..95e541d 100644
--- a/config.go
+++ b/config.go
@@ -91,24 +91,34 @@ func Conf() Config {
return config
}
-// UniquePoolServers returns a []Server where each
-// MediaPool is only represented once.
-func UniquePoolServers() []Server {
- var srvs []Server
+// UniquePoolServers returns a [][]server where each Pool is represented by a []Server
+// of all servers that use one pool
+func UniquePoolServers() [][]Server {
+ var srvs = make(map[string][]Server)
conf := Conf()
-AppendLoop:
+ // every server needs a texturePool property
for _, srv := range conf.Servers {
- for _, s := range srvs {
- if srv.MediaPool == s.MediaPool {
- continue AppendLoop
- }
+ if len(srv.MediaPool) == 0 {
+ srv.MediaPool = srv.Name
}
+ }
+
+ // map all to.. map of slices
+ for _, srv := range conf.Servers {
+ if srvs[srv.MediaPool] != nil {
+ srvs[srv.MediaPool] = append(srvs[srv.MediaPool], srv)
+ } else {
+ srvs[srv.MediaPool] = []Server{srv}
+ }
+ }
- srvs = append(srvs, srv)
+ var res [][]Server
+ for _, srvsPool := range srvs {
+ res = append(res, srvsPool)
}
- return srvs
+ return res
}
// AddServer dynamically configures a new Server at runtime.