Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidaguerre committed Feb 19, 2024
1 parent 99487bf commit e434f8c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions aws/common_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (

// Columns defined on every account-level resource (e.g. aws_iam_access_key)
func commonColumnsForAccountResource() []*plugin.Column {
// set the NamedHydrate property with the memoized version of getCommonColumns

return []*plugin.Column{
{
Name: "partition",
Expand All @@ -35,7 +33,6 @@ func commonColumnsForAccountResource() []*plugin.Column {

// Columns defined on every region-level resource (e.g. aws_ec2_instance)
func commonColumnsForRegionalResource() []*plugin.Column {
// set the NamedHydrate property with the memoized version of getCommonColumns
return []*plugin.Column{
{
Name: "partition",
Expand All @@ -61,7 +58,6 @@ func commonColumnsForRegionalResource() []*plugin.Column {

// Columns defined on every global-region-level resource (e.g. aws_waf_rule)
func commonColumnsForGlobalRegionResource() []*plugin.Column {
// set the NamedHydrate property with the memoized version of getCommonColumns
return []*plugin.Column{
{
Name: "partition",
Expand Down Expand Up @@ -106,12 +102,12 @@ type awsCommonColumnData struct {
Partition, Region, AccountId string
}

// memoize getCommonColumnsUncached
// (getCommonColumnsMemoized is of type NamedHydrateFunc)
// if the caching is required other than per connection, build a cache key for the call and use it in Memoize
// since getCommonColumns is a multi-region call, caching should be per connection per region
var getCommonColumnsMemoized = plugin.HydrateFunc(getCommonColumnsUncached).Memoize(memoize.WithCacheKeyFunction(getCommonColumnsCacheKey))

// declare a wrapper hydrate function to call the memoized function
// - this is required when a memoized function is used for a column defintion
// - this is required when a memoized function is used for a column definition
func getCommonColumns(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
return getCommonColumnsMemoized(ctx, d, h)
}
Expand Down

0 comments on commit e434f8c

Please sign in to comment.