public class SingleRouterFactory extends Object implements RouterFactory
RouterFactory that caches a Router
captured at instantiation instead of producing a new one each time
getRouter(discord4j.rest.http.client.DiscordWebClient) or
getRouter(DiscordWebClient, RouterOptions) is called.
Suited for sharing a router in order to coordinate its work across shards. It is not suited for distributed scenarios where multiple shards exist across processes unless care is taken to properly coordinate each request externally.
| Constructor and Description |
|---|
SingleRouterFactory(Router router)
Create a new
SingleRouterFactory that will always produce the given Router instance. |
| Modifier and Type | Method and Description |
|---|---|
Router |
getRouter(DiscordWebClient httpClient)
Retrieve a
Router configured to process API requests. |
Router |
getRouter(DiscordWebClient httpClient,
RouterOptions routerOptions)
Retrieve a
Router that can be further configured with the given
RouterOptions to process API requests. |
public SingleRouterFactory(Router router)
SingleRouterFactory that will always produce the given Router instance.router - the Router instance that will be produced by this factory.public Router getRouter(DiscordWebClient httpClient)
RouterFactoryRouter configured to process API requests.getRouter in interface RouterFactoryhttpClient - a web client to parameterize the Router creationRouter prepared to process API requestspublic Router getRouter(DiscordWebClient httpClient, RouterOptions routerOptions)
RouterFactoryRouter that can be further configured with the given
RouterOptions to process API requests.getRouter in interface RouterFactoryhttpClient - a web client to parameterize the Router creationrouterOptions - a configuration object to control the behavior of the resulting RouterRouter prepared to process API requests