Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(queue): fix wiring for keiko redis to sql migrator #3191

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions orca-queue-sql/orca-queue-sql.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {
implementation(project(":orca-core"))
implementation(project(":orca-queue"))
api("com.netflix.spinnaker.kork:kork-sql")
api("com.netflix.spinnaker.kork:kork-jedis")
api("com.netflix.spinnaker.keiko:keiko-sql:$keikoVersion")
implementation(project(":orca-sql"))
implementation("com.netflix.spinnaker.keiko:keiko-redis-spring:$keikoVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.netflix.spinnaker.config

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spectator.api.Registry
import com.netflix.spinnaker.kork.jedis.JedisDriverProperties
import com.netflix.spinnaker.orca.q.QueueShovel
import com.netflix.spinnaker.q.Activator
import com.netflix.spinnaker.q.metrics.EventPublisher
Expand All @@ -26,17 +27,18 @@ import com.netflix.spinnaker.q.redis.AbstractRedisQueue
import com.netflix.spinnaker.q.redis.RedisClusterQueue
import com.netflix.spinnaker.q.redis.RedisQueue
import com.netflix.spinnaker.q.sql.SqlQueue
import org.apache.commons.pool2.impl.GenericObjectPoolConfig
import org.jooq.DSLContext
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import redis.clients.jedis.Jedis
import redis.clients.jedis.JedisCluster
import redis.clients.util.Pool
import java.time.Clock
import java.util.Optional
import com.netflix.spinnaker.kork.jedis.JedisPoolFactory

@Configuration
@EnableConfigurationProperties(RedisQueueProperties::class, SqlQueueProperties::class)
Expand All @@ -47,8 +49,10 @@ class SqlRedisQueueShovelConfiguration {
@ConditionalOnBean(SqlQueue::class)
@ConditionalOnProperty(value = ["redis.cluster-enabled"], havingValue = "false", matchIfMissing = true)
fun redisToSqlQueueShovel(
@Value("\${redis.connection:redis://localhost:6379}") mainConnection: String,
@Value("\${redis.timeout:2000}") timeout: Int,
redisPoolConfig: GenericObjectPoolConfig<*>,
queue: SqlQueue,
jedisPool: Pool<Jedis>,
clock: Clock,
publisher: EventPublisher,
mapper: ObjectMapper,
Expand All @@ -57,6 +61,15 @@ class SqlRedisQueueShovelConfiguration {
registry: Registry,
discoveryActivator: Activator
): QueueShovel {
val jedisPool = JedisPoolFactory(registry).build(
"previousQueue",
JedisDriverProperties().apply {
connection = mainConnection
timeoutMs = timeout
poolConfig = redisPoolConfig
},
redisPoolConfig)

val previousQueue = RedisQueue(
queueName = redisQueueProperties.queueName,
pool = jedisPool,
Expand Down