package com.hubspot.baragon.watcher;

import com.google.common.base.Supplier;
import com.google.inject.AbstractModule;
import com.google.inject.Provider;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import com.hubspot.baragon.config.ZooKeeperConfiguration;
import com.hubspot.ringleader.watcher.PersistentWatcher;
import com.hubspot.ringleader.watcher.WatcherFactory;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

public class BaragonWatcherModule extends AbstractModule {

  @Override
  protected void configure() {
    bind(BaragonStateWatcher.class).asEagerSingleton();

    Multibinder.newSetBinder(binder(), BaragonStateListener.class);
  }

  @Baragon
  @Provides
  public CuratorFramework provideCurator(ZooKeeperConfiguration config) {
    CuratorFramework client = CuratorFrameworkFactory.newClient(
            config.getQuorum(),
            config.getSessionTimeoutMillis(),
            config.getConnectTimeoutMillis(),
            new ExponentialBackoffRetry(config.getRetryBaseSleepTimeMilliseconds(), config.getRetryMaxTries()));

    client.start();

    return client.usingNamespace(config.getZkNamespace());
  }

  @Baragon
  @Provides
  @Singleton
  public PersistentWatcher provideWatcher(@Baragon final Provider<CuratorFramework> curatorProvider) {
    return new WatcherFactory(new Supplier<CuratorFramework>() {

      @Override
      public CuratorFramework get() {
        return curatorProvider.get();
      }
    }).dataWatcher("/state-last-updated");
  }
}

@@ -1000,31 +1000,41 @@
 ory.
-newClient(%0A            
+builder()%0A        .connectString(
 conf
@@ -1047,17 +1047,17 @@
 Quorum()
-,
+)
 %0A       
@@ -1049,36 +1049,50 @@
 orum())%0A        
-    
+.sessionTimeoutMs(
 config.getSessio
@@ -1099,33 +1099,33 @@
 nTimeoutMillis()
-,
+)
 %0A            con
@@ -1117,20 +1117,37 @@
         
-    
+.connectionTimeoutMs(
 config.g
@@ -1170,17 +1170,17 @@
 Millis()
-,
+)
 %0A       
@@ -1180,20 +1180,29 @@
         
-    
+.retryPolicy(
 new Expo
@@ -1296,89 +1296,110 @@
 ()))
-;%0A
 %0A    
-client.start();%0A%0A    return client.usingNamespace(config.getZkNamespace())
+    .namespace(config.getZkNamespace())%0A        .build();%0A%0A    client.start();%0A%0A    return client
 ;%0A  

Build curator without NamespaceFacade