/** * Add many services using round robin (a service pool), under this address, using this supplier * * @param address address to register the round robin service pool * @param numServices number of services that will be in the pool * @param serviceInstanceSupplier the supplier that will create the instances for the pool * @return this, fluent. */ default ServiceBundle addRoundRobinService(final String address, final int numServices, final Supplier<Object> serviceInstanceSupplier) { RoundRobinServiceWorkerBuilder roundRobinServiceWorkerBuilder = RoundRobinServiceWorkerBuilder .roundRobinServiceWorkerBuilder().setWorkerCount(numServices); roundRobinServiceWorkerBuilder.setServiceObjectSupplier(serviceInstanceSupplier); ServiceMethodDispatcher serviceMethodDispatcher = roundRobinServiceWorkerBuilder.build(); serviceMethodDispatcher.start(); this.addServiceConsumer(address, serviceMethodDispatcher); return this; }
@Before public void setup() { super.setupLatch(); dispatcher = RoundRobinServiceWorkerBuilder .roundRobinServiceWorkerBuilder() .setFlushInterval(1) .setServiceObjectSupplier(() -> new MultiWorker()) .build(); dispatcher.start(); bundle = serviceBundleBuilder().setAddress("/root").build(); bundle.addServiceConsumer("/workers", dispatcher); bundle.startUpCallQueue(); }
@Before public void setup() { super.setupLatch(); final ShardedServiceWorkerBuilder shardedServiceWorkerBuilder = ShardedServiceWorkerBuilder .shardedServiceWorkerBuilder() .setWorkerCount(10) .setFlushInterval(50) .setServiceObjectSupplier(() -> new ContentRulesEngine()); dispatcher = shardedServiceWorkerBuilder.build(); dispatcher.start(); bundle = serviceBundleBuilder().setAddress("/root").build(); bundle.addServiceConsumer("/workers", dispatcher); bundle.start(); }
default ServiceBundle addRoundRobinService(final String address, final int numServices, final Supplier<Object> serviceInstanceSupplier) { RoundRobinServiceWorkerBuilder roundRobinServiceWorkerBuilder = RoundRobinServiceWorkerBuilder .roundRobinServiceWorkerBuilder().setWorkerCount(numServices); roundRobinServiceWorkerBuilder.setServiceObjectSupplier(serviceInstanceSupplier); ServiceMethodDispatcher serviceMethodDispatcher = roundRobinServiceWorkerBuilder.build(); serviceMethodDispatcher.start(); this.addServiceConsumer(address, serviceMethodDispatcher); return this; }
/** * Add many services using round robin (a service pool), under this address, using this supplier * * @param address address to register the round robin service pool * @param numServices number of services that will be in the pool * @param serviceInstanceSupplier the supplier that will create the instances for the pool * @return this, fluent. */ default ServiceBundle addRoundRobinService(final String address, final int numServices, final Supplier<Object> serviceInstanceSupplier) { RoundRobinServiceWorkerBuilder roundRobinServiceWorkerBuilder = RoundRobinServiceWorkerBuilder .roundRobinServiceWorkerBuilder().setWorkerCount(numServices); roundRobinServiceWorkerBuilder.setServiceObjectSupplier(serviceInstanceSupplier); ServiceMethodDispatcher serviceMethodDispatcher = roundRobinServiceWorkerBuilder.build(); serviceMethodDispatcher.start(); this.addServiceConsumer(address, serviceMethodDispatcher); return this; }