-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
155 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import system, results, std/json | ||
import stew/byteutils | ||
import ../../waku/common/base64, ./json_base_event | ||
import ../../waku/waku_relay | ||
|
||
type JsonTopicHealthChangeEvent* = ref object of JsonEvent | ||
pubsubTopic*: string | ||
topicHealth*: TopicHealth | ||
|
||
proc new*( | ||
T: type JsonTopicHealthChangeEvent, pubsubTopic: string, topicHealth: TopicHealth | ||
): T = | ||
# Returns a TopicHealthChange event as indicated in | ||
# https://rfc.vac.dev/spec/36/#jsonmessageevent-type | ||
|
||
return JsonTopicHealthChangeEvent( | ||
eventType: "relay_topic_health_change", | ||
pubsubTopic: pubsubTopic, | ||
topicHealth: topicHealth, | ||
) | ||
|
||
method `$`*(jsonTopicHealthChange: JsonTopicHealthChangeEvent): string = | ||
$(%*jsonTopicHealthChange) |
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,4 +1,5 @@ | ||
import ../waku_relay/protocol | ||
import ../waku_relay | ||
|
||
type AppCallbacks* = ref object | ||
relayHandler*: WakuRelayHandler | ||
topicHealthChangeHandler*: TopicHealthChangeHandler |
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,3 +1,3 @@ | ||
import ./waku_relay/protocol | ||
import ./waku_relay/[protocol, topic_health] | ||
|
||
export protocol | ||
export protocol, topic_health |
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,19 @@ | ||
import chronos | ||
|
||
import ../waku_core | ||
|
||
type TopicHealth* = enum | ||
UNHEALTHY | ||
MINIMALLY_HEALTHY | ||
SUFFICIENTLY_HEALTHY | ||
|
||
proc `$`*(t: TopicHealth): string = | ||
result = | ||
case t | ||
of UNHEALTHY: "UnHealthy" | ||
of MINIMALLY_HEALTHY: "MinimallyHealthy" | ||
of SUFFICIENTLY_HEALTHY: "SufficientlyHealthy" | ||
|
||
type TopicHealthChangeHandler* = proc( | ||
pubsubTopic: PubsubTopic, topicHealth: TopicHealth | ||
): Future[void] {.gcsafe, raises: [Defect].} |