Ejemplo n.º 1
0
func minionRegistryMaker(c *Config) registry.MinionRegistry {
	var minionRegistry registry.MinionRegistry
	if c.Cloud != nil && len(c.MinionRegexp) > 0 {
		var err error
		minionRegistry, err = registry.MakeCloudMinionRegistry(c.Cloud, c.MinionRegexp)
		if err != nil {
			glog.Errorf("Failed to initalize cloud minion registry reverting to static registry (%#v)", err)
		}
	}
	if minionRegistry == nil {
		minionRegistry = registry.MakeMinionRegistry(c.Minions)
	}
	if c.HealthCheckMinions {
		minionRegistry = registry.NewHealthyMinionRegistry(minionRegistry, &http.Client{})
	}
	if c.MinionCacheTTL > 0 {
		cachingMinionRegistry, err := registry.NewCachingMinionRegistry(minionRegistry, c.MinionCacheTTL)
		if err != nil {
			glog.Errorf("Failed to initialize caching layer, ignoring cache.")
		} else {
			minionRegistry = cachingMinionRegistry
		}
	}
	return minionRegistry
}
Ejemplo n.º 2
0
func minionRegistryMaker(minions []string, cloud cloudprovider.Interface, minionRegexp string, healthCheck bool, cacheTTL time.Duration) registry.MinionRegistry {
	var minionRegistry registry.MinionRegistry
	if cloud != nil && len(minionRegexp) > 0 {
		var err error
		minionRegistry, err = registry.MakeCloudMinionRegistry(cloud, minionRegexp)
		if err != nil {
			glog.Errorf("Failed to initalize cloud minion registry reverting to static registry (%#v)", err)
		}
	}
	if minionRegistry == nil {
		minionRegistry = registry.MakeMinionRegistry(minions)
	}
	if healthCheck {
		minionRegistry = registry.NewHealthyMinionRegistry(minionRegistry, &http.Client{})
	}
	if cacheTTL > 0 {
		cachingMinionRegistry, err := registry.NewCachingMinionRegistry(minionRegistry, cacheTTL)
		if err != nil {
			glog.Errorf("Failed to initialize caching layer, ignoring cache.")
		} else {
			minionRegistry = cachingMinionRegistry
		}
	}
	return minionRegistry
}