Example #1
0
func NewHealthyRegistry(delegate Registry, client client.KubeletHealthChecker, clock util.Clock, ttl time.Duration) Registry {
	h := &HealthyRegistry{
		delegate: delegate,
		client:   client,
	}
	h.cache = util.NewTimeCache(clock, ttl, h.doCheck)
	return h
}
Example #2
0
// NewIPCache makes a new ip caching layer, which will get IP addresses from cp,
// and use clock for deciding when to re-get an IP address.
// Thread-safe.
//
// TODO: when we switch to go1.4, this class would be a good candidate for something
// that could be produced from a template and a type via `go generate`.
func NewIPCache(cp cloudprovider.Interface, clock util.Clock, ttl time.Duration) *ipCache {
	return &ipCache{
		cache: util.NewTimeCache(
			clock,
			ttl,
			func(host string) util.T {
				return getInstanceIPFromCloud(cp, host)
			},
		),
	}
}