Interface DarkModeManager


  • public interface DarkModeManager

    This class allows you to block certain hosts from receiving requests.

    If a host is in "dark mode" then cranker connectors can still register with it, however no requests will be forwarded to those connectors.

    You can acquire an instance of this class by creating a cranker router object and then calling CrankerRouter.darkModeManager()

    • Method Detail

      • enableDarkMode

        void enableDarkMode​(DarkHost host)
        Specifies that the given target destination should not have any requests sent to it.

        Does nothing if the host was already in dark mode.

        Parameters:
        host - The host to block, created with DarkHost.create(InetAddress, Instant, String)
      • disableDarkMode

        void disableDarkMode​(DarkHost host)
        Removes the target from the set of blocked hosts.

        Does nothing if the host was not already in dark mode.

        Parameters:
        host - An IP address previously added to enableDarkMode(DarkHost)
      • darkHosts

        Set<DarkHost> darkHosts()
        The current dark hosts.
        Returns:
        A readonly set of hosts that are currently in dark mode.
      • findHost

        Optional<DarkHost> findHost​(InetAddress address)
        Finds the host associated with the given address, if it is in dark mode.
        Parameters:
        address - The address of the host, e.g. InetAddress.getByName("127.0.0.1")
        Returns:
        The host if it is currently in dark mode; otherwise an empty optional object.