srkukarni commented on a change in pull request #7180: URL: https://github.com/apache/pulsar/pull/7180#discussion_r436156605
########## File path: pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionAssignmentTailer.java ########## @@ -18,56 +18,91 @@ */ package org.apache.pulsar.functions.worker; -import java.io.IOException; -import java.util.function.Function; - +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.api.Message; -import org.apache.pulsar.client.api.PulsarClientException.AlreadyClosedException; +import org.apache.pulsar.client.api.MessageId; +import org.apache.pulsar.client.api.PulsarClientException; import org.apache.pulsar.client.api.Reader; -import org.apache.pulsar.common.util.FutureUtil; +import org.apache.pulsar.client.api.ReaderBuilder; import org.apache.pulsar.functions.proto.Function.Assignment; -import lombok.extern.slf4j.Slf4j; +import java.io.IOException; @Slf4j -public class FunctionAssignmentTailer - implements java.util.function.Consumer<Message<byte[]>>, Function<Throwable, Void>, AutoCloseable { +public class FunctionAssignmentTailer implements AutoCloseable { private final FunctionRuntimeManager functionRuntimeManager; + @Getter private final Reader<byte[]> reader; - private boolean closed = false; + private volatile boolean isRunning = false; Review comment: At start() { shouldStop = false; create the thread and start } At close() { set shoutStop = true, interrupt thread, join and then set it to null; close reader and set it to null } This way I can do start() /close() multiple times ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org