diff options
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 33 |
1 files changed, 30 insertions, 3 deletions
@@ -23,9 +23,10 @@ var configMu sync.RWMutex var loadConfigOnce sync.Once type Server struct { - Name string - Addr string - Fallbacks []string + Name string + Addr string + TexturePool string + Fallbacks []string } // A Config contains information from the configuration file @@ -87,6 +88,32 @@ func Conf() Config { return config } +// UniquePoolServers returns a []server where each Pool is only +// represented once +func UniquePoolServers() []Server { + var srvs []Server + conf := Conf() + + for _, srv := range conf.Servers { + if len(srv.TexturePool) == 0 { + srv.TexturePool = srv.Name + } + } + +AddLoop: + for _, srv := range conf.Servers { + for _, srv2 := range srvs { + if srv.TexturePool == srv2.TexturePool { + continue AddLoop + } + } + + srvs = append(srvs, srv) + } + + return srvs +} + // AddServer appends a server to the list of configured servers. func AddServer(server Server) bool { configMu.Lock() |