As a OpenAPI Terraform plugin user
I want the plugin to cache certain code that is currently being executed multiple times
So that the plugin executes faster
Describe the solution you'd like
Currently the implementation of SpecResource SpecV2Resource does a lot of processing behind the scenes when certain methods are called (eg: GetResourceSchema, GetParentResourceInfo or getResourcePath). These methods are called multiple times in various places of the code making the plugin process the same code redundantly causing the total plugin execution time to increase significantly for each resource execution. The following shows where the methods are being used for the reference at the moment:
openAPIResource.GetResourceSchema() used in multiple places causing lots of redundant code execution. Usages in:
Common.go 99
Common.go 272
Common.go 283
data_source_factory.go 44
data_source_factory.go 132
resource_factory.go 132
resource_factory.go 413
resource_factory.go 505
resource_factory.go 619
resource_factory.go 647
data_source_instance_factory.go 132
openapi_terraofrm_provider_doc_generator.go 123
openapi_terraofrm_provider_doc_generator.go 144
openapi_terraofrm_provider_doc_generator.go 168
openAPIResource.GetParentResourceInfo used:
openapi_v2_resource.go 167
openapi_v2_resource.go 362
resource_factory.go 185
resource_factory.go 297
openapi_v2_spec_analyser.go 131
Common.go 66
Common.go 99
openapi_terraform_provider_doc_generator.go 187
openAPIResource.getResourcePath
openapi_client.go
common.go 52
Acceptance criteria
Scenario: GetResourceSchema() creates a SpecSchemaDefinition the first time is executed, subsequent calls will get the cached object
Given the openapi_v2_resource.go file
When the GetResourceSchema() method is called
Then the first time the method is executed it should cache the generated SpecSchemaDefinition and store it in a local private property of SpecV2Resource (eg: specSchemaDefinitionCached). Hence, the next time the method is executed the cached object would be returned instead
Scenario: GetParentResourceInfo() creates a ParentResourceInfo the first time is executed, subsequent calls will get the cached object
Given the openapi_v2_resource.go file
When the GetParentResourceInfo() method is called
Then the first time the method is executed it should cache the generated ParentResourceInfo and store it in a local private property of SpecV2Resource (eg: parentResourceInfoCached). Hence, the next time the method is executed the cached object would be returned instead
Scenario: getResourcePath() creates a path with the ids resolved the first time is executed, subsequent calls will get the cached object
Given the openapi_v2_resource.go file
When the getResourcePath() method is called
Then the first time the method is executed it should cache the generated path with the ids resolved and store it in a local private property of SpecV2Resource (eg: resolvedPathCached). Hence, the next time the method is executed the cached object would be returned instead
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Checklist (for admin only)
Don't forget to go through the checklist to make sure the issue is created properly:
[x] I have added a corresponding label (feature request) to the issue (right side menu)
[x] I have added this issue to the 'API Terraform Provider' GitHub project (right side menu)
Is your feature request related to a problem?
Describe the solution you'd like
Currently the implementation of SpecResource SpecV2Resource does a lot of processing behind the scenes when certain methods are called (eg: GetResourceSchema, GetParentResourceInfo or getResourcePath). These methods are called multiple times in various places of the code making the plugin process the same code redundantly causing the total plugin execution time to increase significantly for each resource execution. The following shows where the methods are being used for the reference at the moment:
openAPIResource.GetParentResourceInfo used:
openAPIResource.getResourcePath
Acceptance criteria
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Checklist (for admin only)
Don't forget to go through the checklist to make sure the issue is created properly: