Skip to content

Commit

Permalink
refactor: Rename shutdown event to notready event (#97)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrizio Demaria <[email protected]>
  • Loading branch information
fabriziodemaria authored Feb 2, 2024
1 parent 53a0908 commit 5a2bc63
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EventHandler(dispatcher: CoroutineDispatcher) :
ProviderStatus {
private val sharedFlow: MutableSharedFlow<OpenFeatureEvents> = MutableSharedFlow()
private val currentStatus: MutableStateFlow<OpenFeatureEvents> =
MutableStateFlow(OpenFeatureEvents.ProviderShutDown)
MutableStateFlow(OpenFeatureEvents.ProviderNotReady)
private val job = Job()
private val coroutineScope = CoroutineScope(job + dispatcher)

Expand All @@ -40,7 +40,7 @@ class EventHandler(dispatcher: CoroutineDispatcher) :
sharedFlow.collect {
currentStatus.value = it
when (it) {
is OpenFeatureEvents.ProviderShutDown -> {
is OpenFeatureEvents.ProviderNotReady -> {
job.cancelChildren()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.openfeature.sdk.events

sealed interface OpenFeatureEvents {
object ProviderNotReady : OpenFeatureEvents
object ProviderReady : OpenFeatureEvents
data class ProviderError(val error: Throwable) : OpenFeatureEvents
object ProviderStale : OpenFeatureEvents
object ProviderShutDown : OpenFeatureEvents
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class EventsHandlerTest {
val eventHandler = EventHandler(dispatcher)
val provider = TestFeatureProvider(dispatcher, eventHandler)

Assert.assertEquals(OpenFeatureEvents.ProviderShutDown, provider.getProviderStatus())
Assert.assertEquals(OpenFeatureEvents.ProviderNotReady, provider.getProviderStatus())

provider.emitReady()

Expand All @@ -201,6 +201,6 @@ class EventsHandlerTest {

provider.shutdown()

Assert.assertEquals(OpenFeatureEvents.ProviderShutDown, provider.getProviderStatus())
Assert.assertEquals(OpenFeatureEvents.ProviderNotReady, provider.getProviderStatus())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestFeatureProvider(
}

override fun shutdown() {
eventHandler.publish(OpenFeatureEvents.ProviderShutDown)
eventHandler.publish(OpenFeatureEvents.ProviderNotReady)
}

override fun onContextSet(oldContext: EvaluationContext?, newContext: EvaluationContext) {
Expand Down

0 comments on commit 5a2bc63

Please sign in to comment.