homatthew commented on code in PR #3539: URL: https://github.com/apache/gobblin/pull/3539#discussion_r965353884
########## gobblin-runtime/src/main/java/org/apache/gobblin/runtime/messaging/MessageBuffer.java: ########## @@ -0,0 +1,73 @@ +/* + * 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.gobblin.runtime.messaging; + +import java.io.IOException; +import java.util.List; + +/** + * Unidirectional buffer for sending messages from a container to another container listening to the buffer. + * Example use case is for sending messages from taskrunner -> AM. If messages need to be + * sent bi-directionally, use multiple message buffers with different channels + * + * This interface provides the following: + * <ul> + * <li>No guaranteed order delivery</li> + * <li>Single reader</li> + * <li>Multiple concurrent writers</li> + * <li>Messages delivered at most once</li> + * </ul> + */ +public interface MessageBuffer<T> { + /** + * Channel name for the message buffer. If a message is published to a channel on one container, another + * container should be + * @return + */ + String getChannelName(); + + /** + * Publish item to message buffer + * @param item + * @return item successfully added to buffer + * @throws IOException if unable to add message to buffer + */ + void publish(T item) throws IOException; + + /** + * Give callback {@link Consumer} object for processing all published {@link T}. It is safe to subscribe multiple + * consumer objects but only one container reading from a {@link MessageBuffer} + * @throws IOException if unable to fetch messages from buffer + */ + void subscribe(Consumer<T> consumer) throws IOException; Review Comment: Doesn't throw IO Exception anymore -- 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]
