Interface RouterFactoryContext


public interface RouterFactoryContext
Context for RouterFactory initialisation and router creation, providing access to the plugin registry and router identity.
  • Method Details

    • virtualClusterName

      String virtualClusterName()
      Returns the name of the virtual cluster that owns this router.
      Returns:
      the virtual cluster name
    • routerName

      String routerName()
      Returns the name of this router, as declared in the router definition.
      Returns:
      the router name
    • pluginInstance

      <P> P pluginInstance(Class<P> pluginClass, String implementationName)
      Gets a plugin instance for the given plugin type and name.
      Type Parameters:
      P - the plugin type
      Parameters:
      pluginClass - the plugin class
      implementationName - the plugin implementation name
      Returns:
      the plugin instance
      Throws:
      UnknownPluginInstanceException - if the named implementation is unknown
    • routeNames

      Set<String> routeNames()
      Returns the names of the routes configured for this router.

      These are the route names declared in the router definition, not route names that appear in the router's plugin configuration. Router implementations can use this during RouterFactory.initialize(io.kroxylicious.proxy.router.RouterFactoryContext, C) to validate that route names referenced in the plugin configuration actually exist.

      Returns:
      an unmodifiable set of route names
    • pluginImplementationNames

      <P> Set<String> pluginImplementationNames(Class<P> pluginClass)
      Returns the implementation names of the registered instances of the given plugin type.
      Type Parameters:
      P - the plugin type
      Parameters:
      pluginClass - the plugin class
      Returns:
      the set of known implementation names
    • topologyService

      TopologyService topologyService()
      Returns a TopologyService for this router level.

      The runtime creates the underlying topology cache on first call and populates it from METADATA responses flowing through the routing pipeline. If no router at a level calls this method, no cache is created and no cost is incurred.

      When called during RouterFactory.initialize(io.kroxylicious.proxy.router.RouterFactoryContext, C), this triggers cache creation as an opt-in side effect. The returned instance should not be stored in the factory's initialization data.

      When called during RouterFactory.createRouter(io.kroxylicious.proxy.router.RouterFactoryContext, I), this returns a fresh per-connection instance backed by the shared cache. This is the instance the router should use for discovery methods (TopologyService.leaders(java.util.Map<java.lang.String, java.util.Set<java.lang.String>>), TopologyService.coordinators(java.lang.String, byte, java.util.Set<java.lang.String>), etc.).

      Returns:
      the topology service for this router level
    • allowSharedClusterTargets

      void allowSharedClusterTargets()
      Declares that this router supports routes targeting the same cluster.

      By default, the runtime rejects configurations where two routes in the same router resolve to the same cluster (directly or transitively via nested routers), because most routers assume each route is a distinct destination and will produce incorrect results otherwise. Routers that handle this call this method during RouterFactory.initialize(io.kroxylicious.proxy.router.RouterFactoryContext, C) to suppress the check.