Skip to content

Commit

Permalink
Merge pull request #405 from vmware-tanzu/perf-enhancement-394
Browse files Browse the repository at this point in the history
Use memoization to reduce api calls to get list of ResourceTypes
  • Loading branch information
100mik authored Jan 7, 2022
2 parents e3b47f5 + a1a1c66 commit dfb5fca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/kapp/resources/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func NewResourceTypesImpl(coreClient kubernetes.Interface, opts ResourceTypesImp
}

func (g *ResourceTypesImpl) All() ([]ResourceType, error) {
return g.memoizedAll()
}

func (g *ResourceTypesImpl) all() ([]ResourceType, error) {
serverResources, err := g.serverResources()
if err != nil {
return nil, err
Expand Down Expand Up @@ -141,7 +145,7 @@ func (g *ResourceTypesImpl) memoizedAll() ([]ResourceType, error) {
g.memoizedResTypesLock.Lock()
defer g.memoizedResTypesLock.Unlock()

resTypes, err := g.All()
resTypes, err := g.all()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit dfb5fca

Please sign in to comment.