First attempt at SSE backend #3

This commit is contained in:
Ian Renton
2025-12-22 13:02:11 +00:00
parent befaceb2f5
commit fd2986f310
4 changed files with 37 additions and 30 deletions

View File

@@ -52,22 +52,6 @@ def get_alert_provider_from_config(config_providers_entry):
provider_class = getattr(module, config_providers_entry["class"])
return provider_class(config_providers_entry)
# Utility method to add a spot, notifying the web server in case any Server-Sent Event connections need to have data
# sent immediately. If the spot has already expired due to loading old data, it will be ignored.
def add_spot(spot):
if not spot.expired():
spots.add(spot.id, spot, expire=MAX_SPOT_AGE)
if web_server:
web_server.notify_new_spot(spot)
# Utility method to add an alert, notifying the web server in case any Server-Sent Event connections need to have data
# sent immediately. If the alert has already expired due to loading old data, it will be ignored.
def add_alert(alert):
if not alert.expired():
alerts.add(alert.id, alert, expire=MAX_SPOT_AGE)
if web_server:
web_server.notify_new_alert(alert)
# Main function
if __name__ == '__main__':
@@ -98,7 +82,7 @@ if __name__ == '__main__':
for entry in config["spot-providers"]:
spot_providers.append(get_spot_provider_from_config(entry))
for p in spot_providers:
p.setup(spots=spots)
p.setup(spots=spots, web_server=web_server)
if p.enabled:
p.start()
@@ -106,7 +90,7 @@ if __name__ == '__main__':
for entry in config["alert-providers"]:
alert_providers.append(get_alert_provider_from_config(entry))
for p in alert_providers:
p.setup(alerts=alerts)
p.setup(alerts=alerts, web_server=web_server)
if p.enabled:
p.start()