package com.atlassian.bitbucket.mesh.management;

import com.atlassian.bitbucket.mesh.rpc.v1.RpcSidebandLeaderFragment;

import javax.annotation.Nonnull;
import java.io.Closeable;

/**
 * Receives {@link RpcSidebandLeaderFragment sideband fragments} from the control plane.
 */
public interface SidebandReceiver extends Closeable {

    /**
     * Closes the sideband channel.
     */
    @Override
    void close();

    /**
     * Called when a {@link RpcSidebandLeaderFragment fragment} is received from the control plane. The implementation
     * handles the message as appropriate.
     *
     * @param fragment the received fragment
     */
    void onReceive(@Nonnull RpcSidebandLeaderFragment fragment);
}
