-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NATS disconnection notification support for Dacha2
As Dacha2 heavily relies on NATS for its state, this allows the unexpected dissolution of a NATs cluster to trigger a Dacha2 instance to drop being a cache and simply pass through requests to MR until the NATS connection is reestablished. #1187
- Loading branch information
Showing
9 changed files
with
216 additions
and
45 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
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
22 changes: 22 additions & 0 deletions
22
backend/eventing-cloudevents/src/main/kotlin/io/featurehub/events/EventingConnection.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,22 @@ | ||
package io.featurehub.events | ||
|
||
interface EventingConnection { | ||
enum class ConnectionStatus { DISCONNECTED, CONNECTED } | ||
|
||
fun registerForConnectionEvents(handler: (event: ConnectionStatus) -> Unit) | ||
|
||
fun status(): ConnectionStatus | ||
} | ||
|
||
/** | ||
* The default implementation (used by PubSub) ignores disconnection errors. | ||
*/ | ||
class DefaultEventingConnection : EventingConnection { | ||
override fun registerForConnectionEvents(handler: (event: EventingConnection.ConnectionStatus) -> Unit) { | ||
handler(EventingConnection.ConnectionStatus.CONNECTED) | ||
} | ||
|
||
override fun status(): EventingConnection.ConnectionStatus { | ||
return EventingConnection.ConnectionStatus.CONNECTED | ||
} | ||
} |
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.