Description
The new Java Event implementation changes the way plugins or Ruby filter scripts can interact with the Event object, in particular for setting fields values in nested objects. Some implementation specific assumptions cannot be made anymore as we move forward with new implementation strategies and eventually offer new alternate languages APIs.
This brings forward the need to clearly define the Event object API from a plugin or Ruby filter script developer. I believe this API was never formally defined and the 5.0 release cycle would be a good time to correct this.
To help with the evolution of the implementation, we should avoid relying on implementation and language specific idioms and provide a clear API and guidelines to our core objects from a plugin development context.
In that context and precisely for the Event accessors and field reference case, we should adopt the field reference syntax as the only way to manipulate Event inner values and we should document that the returned values when looking up a field reference are copies of the Event values and modifying these values is not guaranteed to automatically update the Event. An updated value must by explicitly written back into the event using the field reference setter syntax.
For example, imagine an Event which has this nested structure:
event["[foo][bar]"] ==> "baz"
Moving forward the following construct to update the value in the [foo][bar]
path would not be supported:
event["foo"]["bar"] = "zab"
Note in the example above, it is assumed that event["foo"]
returns a reference to a Ruby hash that contains the bar
key which can be in-place updated.
Likewise with this same assumption but written a bit differently:
h = event["foo"]
h["bar"] = "zab"
The proper way is to explicitly set an updated value using the complete field reference like this:
event["[foo][bar]"] = "zab"
Or alternatively:
h = event["foo"]
h["bar"] = "zab"
event["foo"] = h