Skip to content

Instantly share code, notes, and snippets.

@ayeshLK
Created March 10, 2023 18:29
Show Gist options
  • Save ayeshLK/40b3e1ba7f793fd14a7cd41e1b716ecf to your computer and use it in GitHub Desktop.
Save ayeshLK/40b3e1ba7f793fd14a7cd41e1b716ecf to your computer and use it in GitHub Desktop.
WeatherReport weatherReport = getWeatherReport(location);
if weatherReport is error {
log:printWarn(string `Error occurred while retrieving weather-report: ${weatherReport.message()}`, stackTrace = weatherReport.stackTrace());
continue;
}
foreach var [newsReceiverId, clientEp] in newsDispatchClients.entries() {
websubhub:ContentDistributionSuccess|error response = clientEp->notifyContentDistribution({
contentType: mime:APPLICATION_JSON,
content: {
"weather-report": weatherReport.toJson()
}
});
if response is websubhub:SubscriptionDeletedError {
log:printWarn("News receiver responded with subscription-delete response, hence removing", id = newsReceiverId);
removeNewsReceiver(newsReceiverId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment