Make @metadata accessible via beat.Event accessor methods#10761
Merged
andrewkroh merged 3 commits intoFeb 20, 2019
Conversation
ded73db to
3454bb8
Compare
This implements a TODO from the beat.Event struct that makes it possible to put/get/delete @metadata values via the accessor methods.
3454bb8 to
dc5a091
Compare
kvch
reviewed
Feb 20, 2019
| } | ||
|
|
||
| func metadataKey(key string) (string, bool) { | ||
| if !strings.HasPrefix(key, "@metadata") { |
Contributor
There was a problem hiding this comment.
I am wondering if it would be safer to check for "@metadata."? What if an event includes the key "@metadata2.keyname and wants to delete @metadata2? If I understand correctly so far, it means that Meta gets deleted.
Member
Author
There was a problem hiding this comment.
I added a test case to show that Delete(@metadataSpecial) doesn't cause Meta to be deleted.
The reason it checks for @metadata is to allow for operations like Put(@metadata, map[string]interface{}{x: y}) and Get(@metadata). When it finds that @metadata as the prefix it then checks to see if the next character is a . so in effect it is checking for @metadata..
kvch
approved these changes
Feb 20, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements a TODO from the beat.Event struct that makes it possible to put/get/delete
@metadatavalues via the accessor methods.