ServicePoolBuilder { public com.bazaarvoice.ostrich.AsyncServicePool<S> buildAsync() { ServicePool<S> pool = buildInternal(); boolean shutdownAsyncExecutorOnClose = (_asyncExecutor == null); if (_asyncExecutor == null) { ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(_serviceName + "-AsyncExecutorThread-%d") .setDaemon(true) .build(); _asyncExecutor = Executors.newCachedThreadPool(threadFactory); } return new AsyncServicePool<>(Ticker.systemTicker(), pool, true, _asyncExecutor, shutdownAsyncExecutorOnClose, _metrics); } private  ServicePoolBuilder(Class<S> serviceType); static ServicePoolBuilder<S> create(Class<S> serviceType); ServicePoolBuilder<S> withHostDiscoverySource(HostDiscoverySource hostDiscoverySource); ServicePoolBuilder<S> withHostDiscovery(final HostDiscovery hostDiscovery); ServicePoolBuilder<S> withServiceFactory(ServiceFactory<S> serviceFactory); ServicePoolBuilder<S> withHealthCheckExecutor(ScheduledExecutorService executor); ServicePoolBuilder<S> withAsyncExecutor(ExecutorService executor); ServicePoolBuilder<S> withCachingPolicy(ServiceCachingPolicy policy); ServicePoolBuilder<S> withPartitionFilter(PartitionFilter partitionFilter); ServicePoolBuilder<S> withPartitionContextAnnotations(); ServicePoolBuilder<S> withPartitionContextAnnotationsFrom(Class<? extends S> annotatedServiceClass); ServicePoolBuilder<S> withLoadBalanceAlgorithm(LoadBalanceAlgorithm algorithm); ServicePoolBuilder<S> withMetricRegistry(MetricRegistry metrics); ServicePoolBuilder<S> withHealthCheckRetryPolicy(HealthCheckRetryDelay healthCheckRetryDelay); com.bazaarvoice.ostrich.ServicePool<S> build(); com.bazaarvoice.ostrich.AsyncServicePool<S> buildAsync(); S buildProxy(RetryPolicy retryPolicy);  }
@Test public void testBuildAsync() { ServicePoolBuilder.create(Service.class) .withServiceFactory(_serviceFactory) .withCachingPolicy(_cachingPolicy) .withHostDiscovery(_hostDiscovery) .withHealthCheckExecutor(_healthCheckExecutor) .withAsyncExecutor(_asyncExecutor) .withPartitionFilter(_partitionFilter) .withMetricRegistry(_metricRegistry) .buildAsync(); }