aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go26
1 files changed, 15 insertions, 11 deletions
diff --git a/config.go b/config.go
index 16e472c..a57ee4d 100644
--- a/config.go
+++ b/config.go
@@ -88,30 +88,34 @@ func Conf() Config {
return config
}
-// UniquePoolServers returns a []server where each Pool 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()
+ // every server needs a texturePool property
for _, srv := range conf.Servers {
if len(srv.TexturePool) == 0 {
srv.TexturePool = srv.Name
}
}
-AddLoop:
+ // map all to.. map of slices
for _, srv := range conf.Servers {
- for _, srv2 := range srvs {
- if srv.TexturePool == srv2.TexturePool {
- continue AddLoop
- }
+ if srvs[srv.TexturePool] != nil {
+ srvs[srv.TexturePool] = append(srvs[srv.TexturePool], srv)
+ } else {
+ srvs[srv.TexturePool] = []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.