All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.lettuce.core.resource.EventLoopResources Maven / Gradle / Ivy

Go to download

Advanced and thread-safe Java Redis client for synchronous, asynchronous, and reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs and much more.

The newest version!
/*
 * Copyright 2019-Present, Redis Ltd. and Contributors
 * All rights reserved.
 *
 * Licensed under the MIT License.
 *
 * This file contains contributions from third-party contributors
 * licensed 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
 *
 *      https://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 io.lettuce.core.resource;

import java.net.SocketAddress;
import java.util.concurrent.ThreadFactory;

import io.netty.channel.Channel;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.socket.DatagramChannel;
import io.netty.util.concurrent.EventExecutorGroup;

/**
 * Interface to encapsulate EventLoopGroup resources.
 *
 * @author Mark Paluch
 * @author Yohei Ueki
 * @since 6.0
 */
public interface EventLoopResources {

    /**
     * Checks if the given {@code type} matches the underlying {@link EventExecutorGroup} type.
     *
     * @param type must not be {@code null}.
     * @return {@code true} if {@code type} is a {@link EventExecutorGroup} of the underlying loop resources.
     */
    boolean matches(Class type);

    /**
     * @return the {@link EventLoopGroup} class.
     */
    Class eventLoopGroupClass();

    /**
     * Create a new {@link EpollEventLoopGroup}.
     *
     * @param nThreads number of threads.
     * @param threadFactory the {@link ThreadFactory}.
     * @return the {@link EventLoopGroup}.
     */
    EventLoopGroup newEventLoopGroup(int nThreads, ThreadFactory threadFactory);

    /**
     * @return the {@link Channel} class.
     */
    Class socketChannelClass();

    /**
     * @return the Domain Socket {@link Channel} class.
     */
    Class domainSocketChannelClass();

    /**
     * @return the {@link DatagramChannel} class.
     * @since 6.1
     */
    Class datagramChannelClass();

    /**
     * @param socketPath the socket file path.
     * @return a domain socket address object.
     */
    SocketAddress newSocketAddress(String socketPath);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy