You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "JinkunLiu (via GitHub)" <gi...@apache.org> on 2026/06/14 16:37:38 UTC
Re: [I] [Feature] Support auto resolve memory reference for passing data across actions. [flink-agents]
JinkunLiu commented on issue #476:
URL: https://github.com/apache/flink-agents/issues/476#issuecomment-4702379526
Hi @wenjin272,
Based on the API shape you proposed, my understanding is that you want to let any python extra field on an Event is automatically carried across actions via `MemoryRef` + `SensoryMemory`.
The Python API would be like this:
```python
@action(MyEvent)
@staticmethod
def first_action(event: Event, ctx: RunnerContext):
event.data = data
# the extra fields on the event are automatically offloaded
# via SensoryMemory + MemoryRef on send
ctx.send_event(event)
@action(MyEvent)
@staticmethod
def second_action(event: Event, ctx: RunnerContext):
content: Any = event.data # auto-resolved on receive
```
To support this on the Java side, I took inspiration from `DescriptorSpec`, add an extras field and use `@JsonAnySetter` / `@JsonAnyGetter`, so the Java API would look like this:
```java
public class Event {
// others.....
private final Map<String, Object> extras = new LinkedHashMap<>();
@JsonAnyGetter
public Map<String, Object> getExtras() {
return extras;
}
@JsonAnySetter
void putExtra(String key, Object value) {
extras.put(key, value);
}
}
@Action(listenEventTypes = {MyEvent.EVENT_TYPE})
public static void firstAction(Event event, RunnerContext ctx) throws Exception {
event.putExtra("data", content);
// extras are automatically offloaded to SensoryMemory as MemoryRefs on send
ctx.sendEvent(event);
}
@Action(listenEventTypes = {MyEvent.EVENT_TYPE})
public static void secondAction(Event event, RunnerContext ctx) throws Exception {
// extras are automatically resolved back from MemoryRef on receive
Object content = event.getExtras().get("data");
}
```
Is this correct? If I've misunderstood any part of the design, feel free to point that.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org