From ecc1964ad92c185f53a0af06e204eac01c7fc164 Mon Sep 17 00:00:00 2001 From: Ice3man Date: Mon, 13 Feb 2023 18:00:25 +0530 Subject: [PATCH] Added optional doNotCache to protocols.ExecuterOptions --- v2/pkg/protocols/protocols.go | 3 +++ v2/pkg/templates/compile.go | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/v2/pkg/protocols/protocols.go b/v2/pkg/protocols/protocols.go index f9e4e03aa..6d0f4c0b6 100644 --- a/v2/pkg/protocols/protocols.go +++ b/v2/pkg/protocols/protocols.go @@ -77,6 +77,9 @@ type ExecuterOptions struct { Operators []*operators.Operators // only used by offlinehttp module + // DoNotCache bool disables optional caching of the templates structure + DoNotCache bool + Colorizer aurora.Aurora WorkflowLoader model.WorkflowLoader ResumeCfg *types.ResumeCfg diff --git a/v2/pkg/templates/compile.go b/v2/pkg/templates/compile.go index 357be9007..d1e63f43c 100644 --- a/v2/pkg/templates/compile.go +++ b/v2/pkg/templates/compile.go @@ -34,8 +34,10 @@ func init() { // //nolint:gocritic // this cannot be passed by pointer func Parse(filePath string, preprocessor Preprocessor, options protocols.ExecuterOptions) (*Template, error) { - if value, err := parsedTemplatesCache.Has(filePath); value != nil { - return value.(*Template), err + if !options.DoNotCache { + if value, err := parsedTemplatesCache.Has(filePath); value != nil { + return value.(*Template), err + } } var reader io.ReadCloser @@ -69,7 +71,9 @@ func Parse(filePath string, preprocessor Preprocessor, options protocols.Execute template.CompiledWorkflow.Options = &options } template.Path = filePath - parsedTemplatesCache.Store(filePath, template, err) + if !options.DoNotCache { + parsedTemplatesCache.Store(filePath, template, err) + } return template, nil }