-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: TogglesCheckedListener and ReadyListener (#56)
* Add bin folder to ignore * feat: Add two new listeners. The TogglesCheckedListener which will be notified each time the poller checks for updates, regardless if there are updates or not or if the check failed. The ReadyListener which will be notified once the RefreshPolicy completes its initialisation process. Adds support for pollInterval = 0 to disable polling, it will only fetch once. Co-authored-by: Gastón Fournier <gastonfournier@gmail.com> fixes: #47, #49
- Loading branch information
Christopher Kolstad
authored
Jun 21, 2023
1 parent
770b220
commit a470087
Showing
12 changed files
with
235 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
package io.getunleash.polling | ||
|
||
class AutoPollingMode(val pollRateDuration: Long, val togglesUpdatedListener: TogglesUpdatedListener = TogglesUpdatedListener { }, val erroredListener: TogglesErroredListener = TogglesErroredListener { }, val pollImmediate: Boolean = true) : PollingMode { | ||
/** | ||
* @param pollRateDuration - How long (in seconds) between each poll | ||
* @param togglesUpdatedListener - A listener that will be notified each time a poll actually updates the evaluation result | ||
* @param erroredListener - A listener that will be notified each time a poll fails. The notification will include the Exception | ||
* @param togglesCheckedListener - A listener that will be notified each time a poll completed. Will be called regardless of the check succeeded or failed. | ||
* @param readyListener - A listener that will be notified after the poller is done instantiating, i.e. has an evaluation result in its cache. Each ready listener will receive only one notification | ||
* @param pollImmediate - Set to true, the poller will immediately poll for configuration and then call the ready listener. Set to false, you will need to call [startPolling()) to actually talk to proxy/Edge | ||
*/ | ||
class AutoPollingMode(val pollRateDuration: Long, | ||
val togglesUpdatedListener: TogglesUpdatedListener? = null, | ||
val erroredListener: TogglesErroredListener? = null, | ||
val togglesCheckedListener: TogglesCheckedListener? = null, | ||
val readyListener: ReadyListener? = null, | ||
val pollImmediate: Boolean = true) : PollingMode { | ||
override fun pollingIdentifier(): String = "auto" | ||
|
||
} |
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,5 @@ | ||
package io.getunleash.polling | ||
|
||
fun interface ReadyListener { | ||
fun onReady(): Unit | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/io/getunleash/polling/TogglesCheckedListener.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,5 @@ | ||
package io.getunleash.polling | ||
|
||
fun interface TogglesCheckedListener { | ||
fun onTogglesChecked(): Unit | ||
} |
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
Oops, something went wrong.