DefGuard / DefGuard/defguard

Improve GatewayEvent routing

Open
#1,944 0 comments 0 reactions 0 assignees View on GitHub
optional for release refactoring
Dominant language
Rust
Stars
2.8k
Forks
115
Avg merge
1d 4h
Merged PRs (30d)
51

Description

We use GatewayEvent (which could be renamed to something better fitting) to trigger gateway updated from various core components.
Since initially we couldn't predict how many gateways we'll be serving we began using a broadcast channel and created a receiver for each connected gateway.
This means that all events are sent to all gateways and need to be filtered out.

Now that we reversed the GW communication we know exactly what messages need to be sent where, so we should refactor the message routing so that only relevant messages are sent to gateway handlers (e.g. if location X is updated only gateways for this location should be sent a message).

Additionaly by introducing a router we could use the same channel for operations related to gateway management within the core itself, for example triggering a reconnect etc.

Also we should consider which events are actually useful and if we should add/remove some types of messages. For example NetworkCreated message seems to be irrelevant to gateway management since gateways are now always assigned to a specific location.

Result: A broadcast channel is no longer used. Gateway handlers receive only messages relevant to their own gateways and filtering boilerplate is removed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.