Skip to content

Commit

Permalink
Revert "fix the bug regarding accessing flags using with context"
Browse files Browse the repository at this point in the history
This reverts commit 8803aee.
  • Loading branch information
vahidlazio committed Jun 19, 2024
1 parent 8803aee commit 5e7422c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 7 additions & 9 deletions Confidence/src/main/java/com/spotify/confidence/Confidence.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Confidence internal constructor(
private val parent: ConfidenceContextProvider? = null,
private val region: ConfidenceRegion = ConfidenceRegion.GLOBAL,
private val debugLogger: DebugLogger?
) : ConfidenceAPI {
) : Contextual, EventSender {
private val removedKeys = mutableListOf<String>()
private val contextMap = MutableStateFlow(initialContext)
private var currentFetchJob: Job? = null
Expand All @@ -50,13 +50,11 @@ class Confidence internal constructor(
private val eventProducers: MutableList<EventProducer> = mutableListOf()

init {
if (parent == null) {
coroutineScope.launch {
contextChanges
.collect {
fetchAndActivate()
}
}
coroutineScope.launch {
contextChanges
.collect {
fetchAndActivate()
}
}
}

Expand Down Expand Up @@ -146,7 +144,7 @@ class Confidence internal constructor(
it.getContext().filterKeys { key -> !removedKeys.contains(key) } + contextMap.value
} ?: contextMap.value

override fun withContext(context: Map<String, ConfidenceValue>): ConfidenceAPI = Confidence(
override fun withContext(context: Map<String, ConfidenceValue>): Confidence = Confidence(
clientSecret,
dispatcher,
eventSenderEngine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ interface Contextual : ConfidenceContextProvider {
fun putContext(context: Map<String, ConfidenceValue>)
fun putContext(key: String, value: ConfidenceValue)
fun removeContext(key: String)
}

interface ConfidenceAPI : Contextual, EventSender
}

0 comments on commit 5e7422c

Please sign in to comment.