Class ServiceManager

java.lang.Object
io.github.simplexdevelopment.scheduler.ServiceManager

public final class ServiceManager extends Object
  • Field Details

  • 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 remove IServices 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 a ServicePool 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 a ServicePool 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 a ServicePool 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 using addToExistingPool(ServicePool, IService...), or by using ServicePool.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 the ServicePool 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 the ServicePool 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

      @Contract(pure=true) public boolean locateServiceWithinPools(IService service)
      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 a ServicePool element which contains the specified service. If no service pool can be found, an empty Mono is returned.