Class ServiceManager
java.lang.Object
io.github.simplexdevelopment.scheduler.ServiceManager
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Set<ServicePool>
A set ofServicePool
s which are currently active. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull reactor.core.publisher.Mono<ServicePool>
addToExistingPool
(@NotNull ServicePool pool, IService... services) @NotNull reactor.core.publisher.Mono<ServicePool>
createServicePool
(String poolName, IService... services) @NotNull reactor.core.publisher.Mono<ServicePool>
emptyServicePool
(String poolName, boolean multithreaded) @NotNull reactor.core.publisher.Mono<ServicePool>
getAssociatedServicePool
(IService service) @NotNull reactor.core.publisher.Flux<ServicePool>
boolean
locateServiceWithinPools
(IService service) @NotNull reactor.core.publisher.Mono<ServicePool>
multithreadedServicePool
(String name, IService... services) @NotNull reactor.core.publisher.Mono<ServicePool>
takeFromExistingPool
(@NotNull ServicePool pool, IService... services)
-
Field Details
-
servicePools
A set ofServicePool
s which are currently active.
-
-
Constructor Details
-
ServiceManager
public ServiceManager()Creates a new instance of the Service Manager class. This class acts as a Service Pool factory, and can be used to create both single and multithreaded Service Pools, empty service pools, as well as retrieve existing Service Pools. It also provides methods for you to add and removeIService
s from the {ServicePool} parameter.
-
-
Method Details
-
createServicePool
@Contract(pure=true, value="_, _ -> new") @NotNull public @NotNull reactor.core.publisher.Mono<ServicePool> createServicePool(String poolName, IService... services) - Parameters:
poolName
- The name of the service pool.services
- The services to register within the service pool.- Returns:
- A
Mono
object which contains aServicePool
element. This service pool will execute each service consecutively within a singular non-blocking thread.
-
multithreadedServicePool
@Contract(pure=true, value="_, _ -> new") @NotNull public @NotNull reactor.core.publisher.Mono<ServicePool> multithreadedServicePool(String name, IService... services) - Parameters:
name
- The name of the service pool.services
- The services to register within the service pool.- Returns:
- A
Mono
object which contains aServicePool
element. This service pool will execute each service across a set of non-blocking threads.
-
emptyServicePool
@Contract(pure=true, value="_, _ -> new") @NotNull public @NotNull reactor.core.publisher.Mono<ServicePool> emptyServicePool(String poolName, boolean multithreaded) - Parameters:
poolName
- The name of the service pool.multithreaded
- Whether the service pool should be multithreaded, or operate upon a single thread.- Returns:
- A
Mono
object which contains aServicePool
element. This pool is empty, meaning it contains no services. Any attempt to run services on this pool while it remains empty will either fail or error. You can add services to this pool by usingaddToExistingPool(ServicePool, IService...)
, or by usingServicePool.addService(IService)
.
-
addToExistingPool
@Contract("_, _ -> new") @NotNull public @NotNull reactor.core.publisher.Mono<ServicePool> addToExistingPool(@NotNull @NotNull ServicePool pool, IService... services) - Parameters:
pool
- The service pool to add to.services
- The services to register within the service pool.- Returns:
- A
Mono
object which contains theServicePool
element that now contains the registered services.
-
takeFromExistingPool
@Contract("_, _ -> new") @NotNull public @NotNull reactor.core.publisher.Mono<ServicePool> takeFromExistingPool(@NotNull @NotNull ServicePool pool, IService... services) - Parameters:
pool
- The service pool to take from.services
- The services to remove from the pool.- Returns:
- A
Mono
object which contains theServicePool
that no longer contains the removed services.
-
getServicePools
@Contract(" -> new") @NotNull public @NotNull reactor.core.publisher.Flux<ServicePool> getServicePools()- Returns:
- A
Flux
object which contains all the service pools currently available.
-
locateServiceWithinPools
- Parameters:
service
- The service to locate.- Returns:
- True if the service is somewhere within a service pool, false otherwise.
-
getAssociatedServicePool
@Contract("_ -> new") @NotNull public @NotNull reactor.core.publisher.Mono<ServicePool> getAssociatedServicePool(IService service) - Parameters:
service
- The service pool to call from.- Returns:
- A
Mono
object which contains aServicePool
element which contains the specified service. If no service pool can be found, an empty Mono is returned.
-