Github user pnowojski commented on a diff in the pull request: https://github.com/apache/flink/pull/4616#discussion_r136063488 --- Diff: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/StreamSink.java --- @@ -31,14 +31,24 @@ private static final long serialVersionUID = 1L; + private transient SimpleSinkContext sinkContext; + public StreamSink(SinkFunction<IN> sinkFunction) { super(sinkFunction); chainingStrategy = ChainingStrategy.ALWAYS; } @Override + public void open() throws Exception { + super.open(); + + this.sinkContext = new SimpleSinkContext<>(); + } + + @Override public void processElement(StreamRecord<IN> element) throws Exception { - userFunction.invoke(element.getValue()); + sinkContext.element = element; + userFunction.invoke(sinkContext, element.getValue()); --- End diff -- wouldn't it be better/simpler to just pass `StreamRecord` to the `userFunction`? `userFunction.invoke(element)`? and instead of adding `SinkContext` as a first argument of the `invoke` method in the sink interface, just change the element type from `IN` to `StreamRecord<IN>`?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---