-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
New Event API proposal #5141
Comments
Is this a typo? Should it be |
Can you add an example for setting metadata?
|
@suyograo did you mean |
oh yeah! Edited :) |
@jordansissel corrected! @suyograo added! |
Note that the new API wouldn't prevent someone from trying to do something like: event.get("[foo][bar]")["c"] = [3, 4] similar to what was done event["[foo][bar]"]["c"] = [3, 4]
# or
event["foo"]["bar"]["c"] = [3, 4] I am hoping that by using the get("...") method it will be more obvious that no value will be set in the event. Thoughts? |
+1 to all the above. People do have the most brutal |
I am +1 for this interface.
I know the high cost, maybe its worth getting some numbers at least to reference in this issue. |
@guyboertje invalidate the whole cache? which cache? the Accessors |
@ph we could but personally I am not sure I see the value. I am trying to balance the forced-safety, at a cost, vs the practical aspect. Here force-safety is meant to prevent developers from making mistakes because of ignorance of the behaviour, and the practical aspect is that there are very little chances this will happen in the first place. The typical flow is to set values in the event and any intermediate objects are discarded after the plugin invocation on the event. There are be corner cases but these are corner cases. Do we want to impose forced-safety to prevent potential corner cases but at the expense of a performance penalty for all usage? I think I'd be ok with providing proper documentation and letting the developer choose if they need to clone or not? |
The performance, was probably for my curiosity. :)
Since we are explicitly removing |
@colinsurprenant - I'm suggesting that for an existing event if someone does |
@guyboertje PathCache does not need to be cleared, it is related to the field references seen in the config, OTOH the |
This has been implemented in #5170 |
As per #5140 we have decided to remove Ruby hash-like API and expose new getter and setter in 5.0.
This is a WIP proposal and is open for discussions. The identified undefined behaviours will probably be the most discussed. Lets keep in mind that this is only the new getter and setter API, other new API proposals should be in their own issue which #5140 will track.
Ruby Event API Proposal
"foo"
or using the nested syntax"[foo]"
or"[foo][bar]"
.Setter
Values are either string, numeric or timestamp scalar values, for example:
Values can be arrays or hashes or nested
When setting hash collections, the hash keys will become fields accessible as fieldref
Mutating a collections after setting it in the Event has an undefined behaviour
This behaviour is certainly up for discussion, the main idea is that if you want to set or update a value in the event you have to use the explicit setter it cannot be assumed that mutating an object that was set in the event will also update it in the event, like this:
We say it is undefined because it is implementation specific and could change at any time so any observed behaviour is not an API contract.
Getter
Returned values are either string, numeric or timestamp scalar values, for example:
Returned values can be arrays or hashes or nested
Mutating a collections after getting it from the Event has an undefined behaviour
One way to avoid an undefined behaviour here would be to always return deep clones of the value at fieldref. This has obviously a rather high cost and I am unsure if this is a cost worth paying?
The text was updated successfully, but these errors were encountered: