Skip to content
Permalink
Browse files

Add zookeeper-testing module (#976)

and various changes to suppport using misk-zookeeper outside of misk
  • Loading branch information...
ryanhall07 committed May 8, 2019
1 parent fe83290 commit 75d658aa1c7f5fea1dd5e01e8131fe5a9b10eb36
@@ -0,0 +1,15 @@
buildscript {
dependencies {
classpath dep.kotlinNoArgPlugin
}
}

apply plugin: 'kotlin-jpa'

dependencies {
compile dep.curatorFramework
compile dep.zookeeper
compile dep.docker
compile project(':misk-testing')
compile project(':misk-zookeeper')
}
@@ -0,0 +1,4 @@
POM_ARTIFACT_ID=misk-zookeeper-testing
POM_NAME=misk-zookeeper-testing
POM_DESCRIPTION=testing module for misk-zookeeper
POM_PACKAGING=jar
@@ -1,4 +1,4 @@
package misk.zookeeper
package misk.zookeeper.testing

import com.github.dockerjava.api.model.ExposedPort
import com.github.dockerjava.api.model.Ports
@@ -1,4 +1,4 @@
package misk.zookeeper
package misk.zookeeper.testing

import com.google.common.util.concurrent.Service
import com.google.inject.Key
@@ -11,6 +11,8 @@ import misk.security.ssl.CertStoreConfig
import misk.security.ssl.SslLoader
import misk.security.ssl.TrustStoreConfig
import misk.service.CachedTestService
import misk.zookeeper.ZkClientFactory
import misk.zookeeper.ZookeeperModule
import org.apache.curator.framework.CuratorFramework
import javax.inject.Inject
import javax.inject.Provider
@@ -15,4 +15,5 @@ dependencies {
testCompile dep.junitApi
testCompile dep.zookeeper
testCompile project(':misk-testing')
testCompile project(':misk-zookeeper-testing')
}
@@ -8,7 +8,7 @@ import misk.logging.getLogger
import org.apache.curator.framework.CuratorFramework
import kotlin.reflect.KClass

internal class ZkService internal constructor(
class ZkService internal constructor(
private val curatorFramework: CuratorFramework,
qualifier: KClass<out Annotation>?
) : AbstractIdleService(), DependentService {
@@ -28,15 +28,16 @@ import kotlin.reflect.KClass
*/
class ZookeeperModule(
private val config: ZookeeperConfig,
private val qualifier: KClass<out Annotation>?
private val qualifier: KClass<out Annotation>? = null
) : KAbstractModule() {
override fun configure() {
bind(keyOf<CuratorFramework>(qualifier)).toProvider(CuratorFrameworkProvider(config)).asSingleton()
val curator = getProvider(keyOf<CuratorFramework>(qualifier))
multibind<Service>().toProvider(object : Provider<ZkService> {
bind(keyOf<ZkService>(qualifier)).toProvider(object : Provider<ZkService> {
override fun get(): ZkService {
return ZkService(curator.get(), qualifier)
}
}).asSingleton()
multibind<Service>().to(keyOf<ZkService>(qualifier))
}
}
@@ -7,7 +7,7 @@ import misk.config.AppName
import misk.inject.KAbstractModule
import misk.tasks.DelayedTask
import misk.tasks.RepeatedTaskQueue
import misk.zookeeper.ZkTestModule
import misk.zookeeper.testing.ZkTestModule
import java.time.Clock

internal class ZkLeaseTestModule : KAbstractModule() {
@@ -6,6 +6,7 @@ import misk.MiskTestingServiceModule
import misk.config.AppNameModule
import misk.testing.MiskTest
import misk.testing.MiskTestModule
import misk.zookeeper.testing.ZkTestModule
import org.apache.curator.framework.CuratorFramework
import org.apache.zookeeper.ZooDefs
import org.apache.zookeeper.data.ACL
@@ -9,6 +9,7 @@ include ':misk-redis'
include ':misk-testing'
include ':misk-zipkin'
include ':misk-zookeeper'
include ':misk-zookeeper-testing'
include ':misk-eventrouter'
include ':misk-events'
include ':misk-jobqueue'

0 comments on commit 75d658a

Please sign in to comment.
You can’t perform that action at this time.