Skip to content

Commit ce1fee3

Browse files
committed
Add list resource function cache
1 parent ae81738 commit ce1fee3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

internal/fwserver/server.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/hashicorp/terraform-plugin-framework/function"
1515
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1616
"github.com/hashicorp/terraform-plugin-framework/internal/logging"
17+
"github.com/hashicorp/terraform-plugin-framework/list"
1718
"github.com/hashicorp/terraform-plugin-framework/provider"
1819
"github.com/hashicorp/terraform-plugin-framework/resource"
1920
)
@@ -172,6 +173,20 @@ type Server struct {
172173
// Provider.Resources() method.
173174
resourceFuncs map[string]func() resource.Resource
174175

176+
// listResourceFuncs is the cached Resource List functions for RPCs that need to
177+
// access resource lists. If not found, it will be fetched from the
178+
// Provider.ListResources() method.
179+
listResourceFuncs map[string]func() list.ListResource
180+
181+
// listResourceTypesDiags is the cached Diagnostics obtained while populating
182+
// listResourceTypes. This is to ensure any warnings or errors are also
183+
// returned appropriately when fetching listResourceTypes.
184+
listResourceTypesDiags diag.Diagnostics
185+
186+
// listResourceTypesMutex is a mutex to protect concurrent listResourceTypes
187+
// access from race conditions.
188+
listResourceTypesMutex sync.Mutex
189+
175190
// resourceTypesDiags is the cached Diagnostics obtained while populating
176191
// resourceTypes. This is to ensure any warnings or errors are also
177192
// returned appropriately when fetching resourceTypes.

0 commit comments

Comments
 (0)