Interface NetService


public interface NetService

A net service provides methods to create resource friendly network clients and servers and resolve host addresses with DNS resolution.

This service should always be used to create clients or servers as it allows to centralize their usage so that thread creation and usage can be optimized based on hardware capabilities.

A typical implementation would rely on the Reactor to obtain optimized event loop groups for the creation of client and server bootstraps.

Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Method Details

    • getTransportType

      NetService.TransportType getTransportType()

      Returns the transport type.

      Returns:
      a transport type
    • createClient

      Bootstrap createClient(SocketAddress socketAddress)

      Creates a client bootstrap that will connect to the specified address with all available threads.

      Parameters:
      socketAddress - the socket address to connect to
      Returns:
      a client bootstrap
    • createClient

      Bootstrap createClient(SocketAddress socketAddress, NetClientConfiguration clientConfiguration)

      Creates a client bootstrap that will connect to the specified address with the specified configuration and all available threads.

      Parameters:
      socketAddress - the socket address to connect to
      clientConfiguration - the client configuration
      Returns:
      a client bootstrap
    • createClient

      Bootstrap createClient(SocketAddress socketAddress, int nThreads) throws IllegalArgumentException

      Creates a client bootstrap that will connect to the specified address with amount of threads.

      Parameters:
      socketAddress - the socket address to connect to
      nThreads - the number of threads to allocate
      Returns:
      a client bootstrap
      Throws:
      IllegalArgumentException - if the specified number of thread exceeds the number of threads available
    • createClient

      Bootstrap createClient(SocketAddress socketAddress, NetClientConfiguration clientConfiguration, int nThreads) throws IllegalArgumentException

      Creates a client bootstrap that will connect to the specified address with the specified configuration and amount of threads.

      Parameters:
      socketAddress - the socket address to connect to
      clientConfiguration - the client configuration
      nThreads - the number of threads to allocate
      Returns:
      a client bootstrap
      Throws:
      IllegalArgumentException - if the specified number of thread exceeds the number of threads available
    • createServer

      ServerBootstrap createServer(SocketAddress socketAddress)

      Creates a server bootstrap that will bind to the specified address with all available threads.

      Parameters:
      socketAddress - the socket address to bind to
      Returns:
      a server bootstrap
    • createServer

      ServerBootstrap createServer(SocketAddress socketAddress, NetServerConfiguration serverConfiguration)

      Creates a server bootstrap that will bind to the specified address with the specified configuration and all available threads.

      Parameters:
      socketAddress - the socket address to bind to
      serverConfiguration - the server configuration
      Returns:
      a server bootstrap
    • createServer

      ServerBootstrap createServer(SocketAddress socketAddress, int nThreads) throws IllegalArgumentException

      Creates a server bootstrap that will bind to the specified address with the specified amount of threads.

      Parameters:
      socketAddress - the socket address to bind to
      nThreads - the number of threads to allocate
      Returns:
      a server bootstrap
      Throws:
      IllegalArgumentException - if the specified number of thread exceeds the number of threads available
    • createServer

      ServerBootstrap createServer(SocketAddress socketAddress, NetServerConfiguration serverConfiguration, int nThreads) throws IllegalArgumentException

      Creates a server bootstrap that will bind to the specified address with the specified server configuration and amount of threads.

      Parameters:
      socketAddress - the socket address to bind to
      serverConfiguration - the server configuration
      nThreads - the number of threads to allocate
      Returns:
      a server bootstrap
      Throws:
      IllegalArgumentException - if the specified number of thread exceeds the number of threads available
    • resolve

      default Mono<InetAddress> resolve(String host)

      Resolves an address associated to the specified host name.

      Parameters:
      host - a host name
      Returns:
      a mono emitting an address
    • resolve

      default Mono<InetSocketAddress> resolve(String host, int port)

      Resolves a socket address associated to the specified host name and port.

      Parameters:
      host - a host name
      port - a port
      Returns:
      a mono emitting a socket address
    • resolve

      Mono<InetSocketAddress> resolve(InetSocketAddress socketAddress)

      Resolves a socket address associated to the socket address.

      Parameters:
      socketAddress - a socket address
      Returns:
      a mono emitting a socket address
    • resolveAll

      default Mono<List<InetAddress>> resolveAll(String host)

      Resolves all addresses associated to the specified host name.

      Parameters:
      host - a host name
      Returns:
      a mono emitting a list of addresses
    • resolveAll

      default Mono<List<InetSocketAddress>> resolveAll(String host, int port)

      Resolves all socket addresses associated to the specified host name and port.

      Parameters:
      host - a host name
      port - a port
      Returns:
      a mono emitting a list of socket addresses
    • resolveAll

      Mono<List<InetSocketAddress>> resolveAll(InetSocketAddress socketAddress)

      Resolves all socket addresses associated to the specified socket address.

      Parameters:
      socketAddress - a socket address
      Returns:
      a mono emitting a list of socket addresses
    • getResolver

      Returns the DNS resolver.

      Returns:
      the name resolver
    • getByteBufAllocator

      ByteBufAllocator getByteBufAllocator()

      Returns a ByteBuf allocator.

      As for event loop groups, this service shall provide optimized ByteBuf allocators.

      Returns:
      a byte buf allocator
    • getDirectByteBufAllocator

      ByteBufAllocator getDirectByteBufAllocator()

      Returns a direct ByteBuf allocator.

      As for event loop groups, this service shall provide optimized ByteBuf allocators.

      Returns:
      a byte buf allocator