Skip to content

Commit

Permalink
feat(core): fast property based kill-switch for pipeline buffering
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed May 4, 2018
1 parent f823e44 commit d90b062
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2018 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.orca.qos

import com.netflix.spinnaker.orca.qos.BufferState.INACTIVE
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.stereotype.Component

@Component
@ConditionalOnMissingBean(BufferStateSupplier::class)
class DefaultBufferStateSupplier :BufferStateSupplier {
override fun get() = INACTIVE
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ package com.netflix.spinnaker.orca.qos
import com.netflix.spinnaker.kork.transientconfig.TransientConfigService
import com.netflix.spinnaker.orca.qos.BufferState.ACTIVE
import com.netflix.spinnaker.orca.qos.BufferState.INACTIVE
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.stereotype.Component

@Component
@ConditionalOnProperty(name = ["qos.bufferingState.supplier"], havingValue = "killSwitch")
class KillSwitchBufferStateSupplier(
private val transientConfigService: TransientConfigService
) : BufferStateSupplier {
override fun get() =
when (transientConfigService.isEnabled("orca.buffer.executions", false)) {
when (transientConfigService.isEnabled("qos.bufferingState.active", false)) {
true -> ACTIVE
false -> INACTIVE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.netflix.spinnaker.orca.qos.BufferState.INACTIVE
import com.netflix.spinnaker.orca.qos.BufferStateSupplier
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component

Expand All @@ -33,6 +34,7 @@ import org.springframework.stereotype.Component
* state. By default, this is 60 seconds.
*/
@Component
@ConditionalOnProperty(name = ["qos.bufferingState.supplier"], havingValue = "activeExecutions")
class ActiveExecutionsBufferStateSupplier(
@Value("\${qos.bufferingState.activeExecutionsThreshold:100}") private val threshold: Int,
private val registry: Registry
Expand Down

0 comments on commit d90b062

Please sign in to comment.