mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 19:36:22 +00:00
apiserver: tri-state watch cache capacity: off, default, value
This commit is contained in:
@@ -11,10 +11,7 @@ go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["cachesize.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
|
||||
],
|
||||
deps = ["//vendor/github.com/golang/glog:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
||||
@@ -23,8 +23,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/apiserver/pkg/registry/generic/registry"
|
||||
)
|
||||
|
||||
type Resource string
|
||||
@@ -111,11 +109,13 @@ func SetWatchCacheSizes(cacheSizes []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetWatchCacheSizeByResource(resource string) int { // TODO this should use schema.GroupResource for lookups
|
||||
// GetWatchCacheSizeByResource returns the configured watch cache size for the given resource.
|
||||
// A nil value means to use a default size, zero means to disable caching.
|
||||
func GetWatchCacheSizeByResource(resource string) (ret *int) { // TODO this should use schema.GroupResource for lookups
|
||||
if value, found := watchCacheSizes[Resource(resource)]; found {
|
||||
return value
|
||||
return &value
|
||||
}
|
||||
return registry.DefaultWatchCacheSize
|
||||
return nil
|
||||
}
|
||||
|
||||
func maxInt(a, b int) int {
|
||||
|
||||
@@ -40,7 +40,7 @@ func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
|
||||
}
|
||||
|
||||
// We explicitly do NOT do any decoration here yet. // TODO determine why we do not want to cache here
|
||||
opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage
|
||||
opts.Decorator = generic.UndecoratedStorage
|
||||
|
||||
store := &genericregistry.Store{
|
||||
Copier: api.Scheme,
|
||||
|
||||
Reference in New Issue
Block a user