xintongsong commented on code in PR #23: URL: https://github.com/apache/flink-agents/pull/23#discussion_r2160199491
########## plan/src/main/java/org/apache/flink/agents/plan/Action.java: ########## @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.agents.plan; + +import org.apache.flink.agents.api.Event; + +import java.util.List; + +/** + * Representation of a workflow action with event listening and function execution. + * + * <p>This class encapsulates a named workflow action that listens for specific event types and + * executes an associated function when those events occur. + */ +public class Action { + private final String name; + private final Function exec; + private final List<Class<? extends Event>> listenEventTypes; + + public Action(String name, Function exec, List<Class<? extends Event>> listenEventTypes) + throws Exception { + this.name = name; + this.exec = exec; + this.listenEventTypes = listenEventTypes; + exec.checkSignature(new Class[] {Event.class}); Review Comment: @lihaosky Let me clarify this a bit. The function of an action should take more arguments than just an `Event`. E.g., a runtime context for emitting new events and accessing resources, and maybe also the state (I said "maybe" because alternatively we can get the state from the context). Those classes will be introduced in follow-up PRs, and the target signature for this check will be updated accordingly. @wenjin272 Checking the signature in `Action`, or introducing another layer of abstraction `ActionFunction` and checking there, I'm okay with either ways. -- 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]
