diff options
author | Riley <riley@e926.de> | 2022-05-01 20:52:17 +0200 |
---|---|---|
committer | Riley <riley@e926.de> | 2022-05-01 20:52:17 +0200 |
commit | fbf490c12b79d979bcc8076dde9a332926ad3642 (patch) | |
tree | 97ebb24fa82357d36b0b895d1135ca54f8325edb /config.go | |
parent | f525780f39758fc1e8fd3c6d3365eaba35cf6646 (diff) |
texturePool things regarding to Issue #101
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -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. |