Class CarrotConfiguration
- java.lang.Object
-
- cn.boboweike.carrot.configuration.CarrotConfiguration
-
public class CarrotConfiguration extends Object
The main class to configure Carrot
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCarrotConfiguration.CarrotConfigurationResult
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CarrotConfiguration.CarrotConfigurationResultinitialize()Initializes Carrot and returns aTaskSchedulerwhich can then be used to register in the IoC framework or to enqueue/schedule some Tasks.CarrotConfigurationuseBackgroundTaskServer()Provides a defaultBackgroundTaskServerthat is configured using a number of threads depending on the amount of CPU.CarrotConfigurationuseBackgroundTaskServer(int workerCount)Provides a defaultBackgroundTaskServerthat is configured using a given number of threads.CarrotConfigurationuseBackgroundTaskServer(BackgroundTaskServerConfiguration configuration)Provides a defaultBackgroundTaskServerthat is configured using the givenBackgroundTaskServerConfigurationCarrotConfigurationuseBackgroundTaskServer(BackgroundTaskServerConfiguration configuration, boolean startBackgroundTaskServer)Provides a defaultBackgroundTaskServerthat is configured using the givenBackgroundTaskServerConfigurationCarrotConfigurationuseBackgroundTaskServerIf(boolean guard)Provides a defaultBackgroundTaskServerif the guard is true and that is configured using a number of threads depending on the amount of CPU.CarrotConfigurationuseBackgroundTaskServerIf(boolean guard, int workerCount)Provides a defaultBackgroundTaskServerif the guard is true and that is configured using a given number of threads.CarrotConfigurationuseBackgroundTaskServerIf(boolean guard, BackgroundTaskServerConfiguration configuration)Provides a defaultBackgroundTaskServerif the guard is true and that is configured using the givenBackgroundTaskServerConfigurationCarrotConfigurationuseBackgroundTaskServerIf(boolean guard, BackgroundTaskServerConfiguration configuration, boolean startBackgroundTaskServer)Provides a defaultBackgroundTaskServerif the guard is true and that is configured using the givenBackgroundTaskServerConfigurationCarrotConfigurationuseDashboard()Provides a dashboard on port 8000CarrotConfigurationuseDashboard(int dashboardPort)Provides a dashboard on the given portCarrotConfigurationuseDashboard(CarrotDashboardWebServerConfiguration configuration)Provides a dashboard using the givenCarrotDashboardWebServerConfigurationCarrotConfigurationuseDashboardIf(boolean guard)Provides a dashboard on port 8000 if the guard is trueCarrotConfigurationuseDashboardIf(boolean guard, int dashboardPort)Provides a dashboard on the given port if the guard is trueCarrotConfigurationuseDashboardIf(boolean guard, CarrotDashboardWebServerConfiguration configuration)Provides a dashboard using the givenCarrotDashboardWebServerConfigurationif the guard is trueCarrotConfigurationuseJmxExtensions()If called, this method will register JMX Extensions to monitor Carrot via JMXCarrotConfigurationuseJmxExtensionsIf(boolean guard)Enables JMX Extensions to monitor Carrot via JMX if the guard is trueCarrotConfigurationuseJsonMapper(JsonMapper jsonMapper)TheJsonMapperto transform tasks to json in the databaseCarrotConfigurationuseMicroMeter(CarrotMicroMeterIntegration microMeterIntegration)Allows integrating MicroMeter metrics into CarrotCarrotConfigurationusePartitioner(Partitioner partitioner)Allows to set the Partitioner that Carrot will use.CarrotConfigurationuseStorageProvider(PartitionedStorageProvider storageProvider)Allows to set the PartitionedStorageProvider that Carrot will use.CarrotConfigurationuseTaskActivator(TaskActivator taskActivator)TheTaskActivatoris used to resolve tasks from the IoC frameworkCarrotConfigurationuseTaskDetailsGenerator(TaskDetailsGenerator taskDetailsGenerator)Specifies whichTaskDetailsGeneratorto use.CarrotConfigurationwithTaskFilter(TaskFilter... taskFilters)Allows setting extra TaskFilters or to provide another implementation of theRetryFilter
-
-
-
Method Detail
-
useJsonMapper
public CarrotConfiguration useJsonMapper(JsonMapper jsonMapper)
TheJsonMapperto transform tasks to json in the database- Parameters:
jsonMapper- theJsonMapperto use- Returns:
- the same configuration instance which provides a fluent api
-
useTaskActivator
public CarrotConfiguration useTaskActivator(TaskActivator taskActivator)
TheTaskActivatoris used to resolve tasks from the IoC framework- Parameters:
taskActivator- theTaskActivatorto use- Returns:
- the same configuration instance which provides a fluent api
-
useStorageProvider
public CarrotConfiguration useStorageProvider(PartitionedStorageProvider storageProvider)
Allows to set the PartitionedStorageProvider that Carrot will use.- Parameters:
storageProvider- the PartitionedStorageProvider to use- Returns:
- the same configuration instance which provides a fluent api
-
usePartitioner
public CarrotConfiguration usePartitioner(Partitioner partitioner)
Allows to set the Partitioner that Carrot will use. If not configured, the defaultRandomPartitionerwill be used.- Parameters:
partitioner- the Partitioner to use- Returns:
- the same configuration instance with provides a fluent api
-
withTaskFilter
public CarrotConfiguration withTaskFilter(TaskFilter... taskFilters)
Allows setting extra TaskFilters or to provide another implementation of theRetryFilter- Parameters:
taskFilters- the taskFilters to use for each task.- Returns:
- the same configuration instance which provides a fluent api
-
useBackgroundTaskServer
public CarrotConfiguration useBackgroundTaskServer()
Provides a defaultBackgroundTaskServerthat is configured using a number of threads depending on the amount of CPU.- Returns:
- the same configuration instance which provides a fluent api
-
useBackgroundTaskServerIf
public CarrotConfiguration useBackgroundTaskServerIf(boolean guard)
Provides a defaultBackgroundTaskServerif the guard is true and that is configured using a number of threads depending on the amount of CPU.- Parameters:
guard- whether to start a BackgroundTaskServer or not.- Returns:
- the same configuration instance which provides a fluent api
-
useBackgroundTaskServer
public CarrotConfiguration useBackgroundTaskServer(int workerCount)
Provides a defaultBackgroundTaskServerthat is configured using a given number of threads.- Parameters:
workerCount- the number of worker threads to use- Returns:
- the same configuration instance which provides a fluent api
-
useBackgroundTaskServerIf
public CarrotConfiguration useBackgroundTaskServerIf(boolean guard, int workerCount)
Provides a defaultBackgroundTaskServerif the guard is true and that is configured using a given number of threads.- Parameters:
guard- whether to start a BackgroundTaskServer or not.workerCount- the number of worker threads to use- Returns:
- the same configuration instance which provides a fluent api
-
useBackgroundTaskServer
public CarrotConfiguration useBackgroundTaskServer(BackgroundTaskServerConfiguration configuration)
Provides a defaultBackgroundTaskServerthat is configured using the givenBackgroundTaskServerConfiguration- Parameters:
configuration- the configuration for the backgroundTaskServer to use- Returns:
- the same configuration instance which provides a fluent api
-
useBackgroundTaskServer
public CarrotConfiguration useBackgroundTaskServer(BackgroundTaskServerConfiguration configuration, boolean startBackgroundTaskServer)
Provides a defaultBackgroundTaskServerthat is configured using the givenBackgroundTaskServerConfiguration- Parameters:
configuration- the configuration for the backgroundTaskServer to usestartBackgroundTaskServer- whether to start the background task server immediately- Returns:
- the same configuration instance which provides a fluent api
-
useBackgroundTaskServerIf
public CarrotConfiguration useBackgroundTaskServerIf(boolean guard, BackgroundTaskServerConfiguration configuration)
Provides a defaultBackgroundTaskServerif the guard is true and that is configured using the givenBackgroundTaskServerConfiguration- Parameters:
guard- whether to start a BackgroundTaskServer or not.configuration- the configuration for the backgroundTaskServer to use- Returns:
- the same configuration instance which provides a fluent api
-
useBackgroundTaskServerIf
public CarrotConfiguration useBackgroundTaskServerIf(boolean guard, BackgroundTaskServerConfiguration configuration, boolean startBackgroundTaskServer)
Provides a defaultBackgroundTaskServerif the guard is true and that is configured using the givenBackgroundTaskServerConfiguration- Parameters:
guard- whether to create a BackgroundTaskServer or not.configuration- the configuration for the backgroundTaskServer to usestartBackgroundTaskServer- whether to start the background task server immediately- Returns:
- the same configuration instance which provides a fluent api
-
useDashboard
public CarrotConfiguration useDashboard()
Provides a dashboard on port 8000- Returns:
- the same configuration instance which provides a fluent api
-
useDashboardIf
public CarrotConfiguration useDashboardIf(boolean guard)
Provides a dashboard on port 8000 if the guard is true- Parameters:
guard- whether to start a Dashboard or not.- Returns:
- the same configuration instance which provides a fluent api
-
useDashboard
public CarrotConfiguration useDashboard(int dashboardPort)
Provides a dashboard on the given port- Parameters:
dashboardPort- the port on which to start theCarrotDashboardWebServer- Returns:
- the same configuration instance which provides a fluent api
-
useDashboardIf
public CarrotConfiguration useDashboardIf(boolean guard, int dashboardPort)
Provides a dashboard on the given port if the guard is true- Parameters:
guard- whether to start a Dashboard or not.dashboardPort- the port on which to start theCarrotDashboardWebServer- Returns:
- the same configuration instance which provides a fluent api
-
useDashboard
public CarrotConfiguration useDashboard(CarrotDashboardWebServerConfiguration configuration)
Provides a dashboard using the givenCarrotDashboardWebServerConfiguration- Parameters:
configuration- theCarrotDashboardWebServerConfigurationto use- Returns:
- the same configuration instance which provides a fluent api
-
useDashboardIf
public CarrotConfiguration useDashboardIf(boolean guard, CarrotDashboardWebServerConfiguration configuration)
Provides a dashboard using the givenCarrotDashboardWebServerConfigurationif the guard is true- Parameters:
guard- whether to start a Dashboard or not.configuration- theCarrotDashboardWebServerConfigurationto use- Returns:
- the same configuration instance which provides a fluent api
-
useJmxExtensions
public CarrotConfiguration useJmxExtensions()
If called, this method will register JMX Extensions to monitor Carrot via JMX- Returns:
- the same configuration instance which provides a fluent api
-
useJmxExtensionsIf
public CarrotConfiguration useJmxExtensionsIf(boolean guard)
Enables JMX Extensions to monitor Carrot via JMX if the guard is true- Parameters:
guard- whether to start the JXM Extensions or not.- Returns:
- the same configuration instance which provides a fluent api
-
useMicroMeter
public CarrotConfiguration useMicroMeter(CarrotMicroMeterIntegration microMeterIntegration)
Allows integrating MicroMeter metrics into Carrot- Parameters:
microMeterIntegration- the CarrotMicroMeterIntegration- Returns:
- the same configuration instance which provides a fluent api
-
useTaskDetailsGenerator
public CarrotConfiguration useTaskDetailsGenerator(TaskDetailsGenerator taskDetailsGenerator)
Specifies whichTaskDetailsGeneratorto use.- Parameters:
taskDetailsGenerator- the TaskDetailsGenerator to use.- Returns:
- the same configuration instance which provides a fluent api
-
initialize
public CarrotConfiguration.CarrotConfigurationResult initialize()
Initializes Carrot and returns aTaskSchedulerwhich can then be used to register in the IoC framework or to enqueue/schedule some Tasks.- Returns:
- a TaskScheduler to enqueue/schedule new tasks
-
-