-
Notifications
You must be signed in to change notification settings - Fork 147
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
Atomic produce and consume actions #677
Comments
@cdavernas, can you evolve a little bit your description (maybe including an example)? Not sure if I understood. We already have the |
@ricardozanini We do, but the produceEventRef property is required: no way to just consume an event. I don't see why I should have to produce a bogus event just to consume one. I get the 'asyncOperation' rationale behind it, but it is too restrictive IMO, especially in an event-driven world where the consumption of an event is the topmost priority => the consumption of an event drives it all. We could just mark that property as non-required, but then the actual objet gets confusing with different properties that do the same thing: reference an event. Example of what I'm proposing: ...
actions:
- name: Notify User about completion
eventRef:
refName: MyProducedEvent
kind: produce # *
data: {
...
}
- name: Do something else
functionRef: a-test-function
- name: Wait for something to happen
eventRef:
refName: MyConsumedEvent
kind: consume# *
dataFilter: {
...
}
...
a. Determine the action of the eventRef by consulting the eventDefinition's b. Remove the (IMO useless) |
I would as well propose to remove the non-ubiquitous, obsolete If need be for that concept, you can achieve it yourself by assembling one produce event and one consume event actions. |
Think the reason for this is the event definition "source" property. If its consumed event then this has to be set to match the source where to consume from. if it's produced then runtime has to set the source. so kind is "kinda" hehe, needed imo unless we say its not used when producing this event which is imo worse user experience maybe. i am not sure in how much % of cases you would consume and produce the exact same event definition, can you show example? |
Well, that was another of my concerns, actually. IMO, source should NOT be required when consuming. You could very well filter by source and/OR type. |
source is required attribute by CE https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md#required-attributes |
Well, it's not a personal use case, just a reasoning, but I guess something like: to consume a "Hello" event from peers, shape it, then route it down to another group of peers: only the |
@tsurdilo Yes, but we are speaking of consuming (not producing) events: it's not because the spec mandates that CE must have a source that we should force user to filter on it!!! Otherwise, we should also add |
I think event defs are cheap to define. we could either leave it as is and deal with the duplication thats currently a must, or add on event defs another enum type for kind maybe "dual" or something and then document that in source you would have to set both producers (since CE allows more than one). For this however we would also i guess need some sort of hook for the source produced by the runtime which to me seems not optimal. |
i personally like the eventRef kind lookup from the event def referenced, idk, seems natural to describe imo |
@tsurdilo yeah maybe, it's not the point of my feature request anyways. I just think that there is no added value to know that an event is gonna be consumed or produced in other places than in the action, so IMHO it's an obsolete property. But then again, doesn't really matter either, so let's leave it if you guys think it adds readability ;) |
ok :) from the eventRef perspective if its more clear to have "produceEventRef" and "consumeEventRef" or similar, yeah thats fine imo. |
Which is the difference between consumeEventRef and a not starting event state? In my opinion there is a duality there. I would propose to delete consumeEventRef and just keep produceEventRef. |
I tend to agree, There might be a "trap" there: even if in the case of In the case of In the case of As for |
One is an action, which is chainable, the other is a whole state. I dont see the problem to have both living happily together, though. |
@tsurdilo I think we can drop the - event:
type: openpr
source: /github.com/serverlessworkflow/specification/pulls/122
kind: consumed In this situation, a workflow author would just add a dummy value that won't mean anything, and the instance would filter it either by regexp in the source or type. I'll read the whole thread later. This source-required attribute is something I needed to bring up for quite a while. |
And being a required attribute in the CE spec doesn't matter to us in the workflow definition. We can add a remark in the spec warning users that it's a required attribute. But needless to say, the CE SDKs will do their job and fail while parsing. Or any other implementations of the CE spec would do. |
another thing we could do is change the event def "source" to "consumedSource" or something and then say that if the event is produced the runtime would set it..thats fair too imo and then you can remove the "kind" |
@fjtirado Actually, the difference resides in the fact that the |
Yes, but you can also use an eventState to consume just one event type. I think we should avoid two ways of doing the same thing. |
I would not do that: it will complicate things and will need another property if you want to filter a consumed event by source, which you should definitly be able to do (but should not be forced to). What I'm proposing regard that specific point is to make the |
got it. ok thanks for explaining, ok so you want to offload the source to runtime if its not set? go for it |
Yes, maybe. But I feel this is a side effect of proposed feature, that should be addressed only if and when this feature is addressed. To summarize: We have a construct that is an opiniated aggregate of a produce and a consume event actions. Opiniated as well is the order in which actions can be performed: produce then (possibly not) consume. At the moment we only support:
Because of this, we forbid perfectly normal and widely used events flow, such as:
What I propose would address that, with minor impact and cleaner/better readability has a result IMO. |
@tsurdilo @ricardozanini @fjtirado @JBBianchi What do you guys think? Can I open a PR? |
I think the proposal we had a while ago to refactor the I'd go for it but try to avoid doing the same thing twice like @fjtirado pointed out to avoid jeopardizing people's understanding. |
I think we can discuss the details on the PR, yes. But I would like to insist in the current duplicity between consumeEventRef and Event state. you can perfectly acompplish consumeEventRef functionality with an Event state with just one onEvent, while the only way to publish an event is through produceEventRef. We need to addess that, in my opinion we eiter remove consumeEventRef or we remove Event state (and use consumeEventRef and parallel/swith state to achieve the same) |
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
[Fix #677] Atomic produce and consume actions
What would you like to be added:
Atomic produce and consume actions, meaning splitting the actual event action into two new actions: produceEvent and consumeEvent.
Why is this needed:
The text was updated successfully, but these errors were encountered: