This repository has been archived by the owner on Oct 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(queue): mysql 5.7 compatible queue implementation (#60)
- Loading branch information
Showing
19 changed files
with
1,423 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apply from: "$rootDir/gradle/spek.gradle" | ||
|
||
dependencies { | ||
api project(":keiko-core") | ||
api "com.fasterxml.jackson.core:jackson-databind" | ||
api "com.fasterxml.jackson.module:jackson-module-kotlin" | ||
api "org.funktionale:funktionale-partials" | ||
api "com.github.ben-manes.caffeine:guava" | ||
|
||
implementation "com.netflix.spinnaker.kork:kork-core" | ||
implementation "com.netflix.spinnaker.kork:kork-exceptions" | ||
implementation "com.netflix.spinnaker.kork:kork-sql" | ||
implementation "de.huxhorn.sulky:de.huxhorn.sulky.ulid" | ||
implementation "io.github.resilience4j:resilience4j-retry" | ||
implementation "javax.validation:validation-api" | ||
implementation "org.jooq:jooq" | ||
|
||
testImplementation project(":keiko-tck") | ||
testImplementation "com.netflix.spinnaker.kork:kork-sql-test" | ||
testImplementation "org.testcontainers:mysql" | ||
testImplementation "mysql:mysql-connector-java" | ||
} |
68 changes: 68 additions & 0 deletions
68
keiko-sql/src/main/kotlin/com/netflix/spinnaker/config/SqlQueueConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.netflix.spinnaker.config | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.netflix.spinnaker.q.metrics.EventPublisher | ||
import com.netflix.spinnaker.q.migration.SerializationMigrator | ||
import com.netflix.spinnaker.q.sql.SqlDeadMessageHandler | ||
import com.netflix.spinnaker.q.sql.SqlQueue | ||
import org.jooq.DSLContext | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean | ||
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 java.time.Clock | ||
import java.util.Optional | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(SqlQueueProperties::class) | ||
@ConditionalOnProperty( | ||
value = ["keiko.queue.sql.enabled"], | ||
havingValue = "true", | ||
matchIfMissing = false) | ||
class SqlQueueConfiguration { | ||
|
||
companion object { | ||
const val SCHEMA_VERSION = 1 | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(name = ["queue"]) | ||
fun queue( | ||
jooq: DSLContext, | ||
clock: Clock, | ||
mapper: ObjectMapper, | ||
deadMessageHandler: SqlDeadMessageHandler, | ||
publisher: EventPublisher, | ||
serializationMigrator: Optional<SerializationMigrator>, | ||
properties: SqlQueueProperties | ||
) = | ||
SqlQueue( | ||
queueName = properties.queueName, | ||
schemaVersion = SCHEMA_VERSION, | ||
jooq = jooq, | ||
clock = clock, | ||
lockTtlSeconds = properties.lockTtlSeconds, | ||
mapper = mapper, | ||
serializationMigrator = serializationMigrator, | ||
ackTimeout = properties.ackTimeout, | ||
deadMessageHandlers = listOf(deadMessageHandler), | ||
publisher = publisher, | ||
sqlRetryProperties = properties.retries | ||
) | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(name = ["sqlDeadMessageHandler"]) | ||
fun sqlDeadMessageHandler( | ||
jooq: DSLContext, | ||
clock: Clock, | ||
properties: SqlQueueProperties | ||
) = | ||
SqlDeadMessageHandler( | ||
deadLetterQueueName = properties.deadLetterQueueName, | ||
schemaVersion = SCHEMA_VERSION, | ||
jooq = jooq, | ||
clock = clock, | ||
sqlRetryProperties = properties.retries | ||
) | ||
} |
Oops, something went wrong.