package com.atlassian.bitbucket.mesh.network;

import javax.annotation.Nonnull;

/**
 * Provides access to {@link MeshChannel channels} connected to other {@link MeshNode nodes} in the topology.
 */
public interface ChannelRegistry {

    /**
     * Retrieves a channel that can be used to send requests to the specified node. If no channel exists, a new
     * channel is opened. Callers should release references to the channel as soon as their immediate processing
     * is complete; topology updates can render existing channels obsolete.
     *
     * @param node the node to retrieve a channel for
     * @return a channel connected to the specified node
     */
    @Nonnull
    MeshChannel getChannel(@Nonnull MeshNode node);
}
