Skip to content

Commit

Permalink
Merge pull request #50 from jeyrschabu/fixlocking
Browse files Browse the repository at this point in the history
fix(locking): duration in millis and not seconds
  • Loading branch information
jeyrschabu authored Jun 5, 2018
2 parents 5713d31 + 9e07366 commit 2a292ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package com.netflix.spinnaker.swabbie

import com.netflix.spinnaker.config.LockingConfigurationProperties
import com.netflix.spinnaker.kork.lock.LockManager
import org.springframework.stereotype.Component
import java.time.Duration


@Component
class LockingService(
private val lockingConfigurationProperties: LockingConfigurationProperties,
private val lockManager: LockManager
private val lockManager: LockManager,
private val lockingConfigurationProperties: LockingConfigurationProperties
) : LockManager by lockManager {
val swabbieMaxLockDuration: Duration
get() = Duration.ofSeconds(lockingConfigurationProperties.maximumLockDurationMillis!!)
get() = Duration.ofMillis(lockingConfigurationProperties.maximumLockDurationMillis!!)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import com.netflix.spectator.api.Registry
import com.netflix.spinnaker.config.LockingConfigurationProperties
import com.netflix.spinnaker.kork.jedis.RedisClientDelegate
import com.netflix.spinnaker.kork.jedis.lock.RedisLockManager
import com.netflix.spinnaker.kork.lock.LockManager
import com.netflix.spinnaker.swabbie.LockingService
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.time.Duration
import java.util.*

@Configuration
Expand All @@ -35,6 +36,12 @@ import java.util.*
open class LockingConfiguration(
private val lockingConfigurationProperties: LockingConfigurationProperties
) {

@Bean
open fun lockingService(lockManager: LockManager): LockingService {
return LockingService(lockManager, lockingConfigurationProperties)
}

@Bean
open fun lockManager(
clock: Clock,
Expand All @@ -52,8 +59,5 @@ open class LockingConfiguration(
Optional.of(lockingConfigurationProperties.leaseDurationMillis)
)
}

internal val RedisLockManager.swabbieLockDuration: Duration
get() = Duration.ofSeconds(lockingConfigurationProperties.maximumLockDurationMillis!!)
}

0 comments on commit 2a292ed

Please sign in to comment.