xintongsong commented on issue #424:
URL: https://github.com/apache/flink-agents/issues/424#issuecomment-3988727542
@addu390 Thanks for volunteering on this. The issue is up for grabs. But
before moving to the code implementation, could we get aligned with the design
first?
The description of the issue might be too brief and the example
`ctx.send_event(identifier="MyEvent", field1="test", field2=1)` is also the
final design and might be misleading.
The purposes of this issue are:
1. To simplify the definition of custom events. Not need to define the event
class before using it.
2. To support cross-language action orchestration, i.e., sending an event in
a java implemented action, that triggers a python implemented action. This
currently requires defining the two identical event classes in java and python
and the serialization between them.
The rough idea is to represent all events with one `Event` class, with a few
required fields (e.g., type) and a list/map of custom fields. In this way, only
this one class needs to be implemented in both java and python, which is done
by the framework.
With this unified `Event`, there could be multiple ways (APIs) of creating
and accessing Events. Below are some preliminary ideas. I haven't thought them
through carefully yet.
```
Map properties = new HashMap();
properties.put("key1", "value1");
Event event1 = new Event("CustomEvent", properties);
event1.setProperty("key2", "value2"); // or make Event immutable, all
properties must be set on instantiation
ctx.sendEvent(event1);
Event event2 = Event.fromJson("{"type": "CustomEvent", "key1": "value1",
"key2": "value2"}"); // validate required fields exist
ctx.sendEvent(event2);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]