aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorRiley <riley@e926.de>2022-05-01 20:52:17 +0200
committerRiley <riley@e926.de>2022-05-01 20:52:17 +0200
commitfbf490c12b79d979bcc8076dde9a332926ad3642 (patch)
tree97ebb24fa82357d36b0b895d1135ca54f8325edb /config.go
parentf525780f39758fc1e8fd3c6d3365eaba35cf6646 (diff)
texturePool things regarding to Issue #101
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.