-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(multiproto): missing previous InternalEvent
s output when ExecuteWithResults
#5967
base: dev
Are you sure you want to change the base?
Conversation
…teWithResults` Signed-off-by: Dwi Siswanto <git@dw1.io>
WalkthroughThe pull request modifies the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
InternalEvent\
s output when \ExecuteWithResults\
InternalEvent
s output when ExecuteWithResults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/tmplexec/multiproto/multi.go (1)
96-102
: Simplify key construction usingfmt.Sprintf
Consider using
fmt.Sprintf
to construct the keys for theprevious
map. This simplifies the code and enhances readability by eliminating the need for astrings.Builder
.Apply this diff to simplify the key construction:
- builder := &strings.Builder{} for k, v := range event.InternalEvent { - builder.WriteString(ID) - builder.WriteString("_") - builder.WriteString(k) - _ = previous.Set(builder.String(), v) - builder.Reset() + key := fmt.Sprintf("%s_%s", ID, k) + _ = previous.Set(key, v) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/tmplexec/multiproto/multi.go
(3 hunks)
🔇 Additional comments (6)
pkg/tmplexec/multiproto/multi.go (6)
5-5
: Importing thestrings
package is necessary for key constructionThe addition of the
strings
package is appropriate for string manipulation in the key construction logic.
13-13
: Utilizingmapsutil
andstringsutil
enhances utility functionsImporting
mapsutil
andstringsutil
provides necessary utility functions for map operations and string manipulations.
65-65
: Thread-safe initialization of theprevious
mapInitializing the
previous
map withmapsutil.NewSyncLockMap[string, any]()
ensures thread-safe operations, which is crucial for concurrent executions.
88-134
: Effective inline callback to handle protocol resultsThe inline definition of the callback function within
ExecuteWithResults
improves code locality and clarity. Passingprevious.GetAll()
and updating theprevious
map within the callback effectively manages dynamic values between protocol executions.
108-129
: Ensure proper handling of dynamic values with multiple entriesThe current logic correctly handles dynamic values when there's more than one value by indexing them. Verify that all necessary cases are covered and that the indexing aligns with expected usage in subsequent protocols.
131-133
: Re-evaluating variables after each protocol executionRe-evaluating and merging the variables into the template context after each protocol ensures that any changes are appropriately reflected in subsequent executions.
Proposed changes
Close #5748
Proof of Concept
Checklist
Summary by CodeRabbit