Drop the module leader recompute event

The queue event did two things: set the routing-changed flag, which the lifecycle
event of the same change already sets, and deliver the leader-change info log. It
cost an extra raft INSERT per connect/disconnect, two GetForLeaderElection reads per
lifecycle event used for nothing else, a payload kind, a compaction key and a
subscription-service method that only logged.

The leader is now logged where it is published: the address-list emission logs the
leader it just sent, and the routing rebuild logs one summary line with the leaders
it published. Modules without election stay silent, as before.

A future self-election needs a recompute trigger that also re-broadcasts the address
list; that event will be added when the requirement exists, not carried as a no-op.
This commit is contained in:
komissarovyv committed 2026-11-19 12:57:28 +03:00
1 parent a8a475435c
commit 439e6f5ebf
9 files changed
+159 -553

No files matched your search

+1 -5
View File
@@ -11,7 +11,6 @@ import (
type SubscriptionService interface {
NotifyConfigChanged(ctx context.Context, moduleId string) error
NotifyBackendsChanged(ctx context.Context, moduleId string) error
NotifyModuleLeaderRecompute(ctx context.Context, recompute entity.PayloadModuleLeaderRecompute)
NotifyRoutingChanged(ctx context.Context) error
}
@@ -36,8 +35,7 @@ func (h Handler) Handle(ctx context.Context, events []entity.Event) {
payload := event.Payload.Value
routingChanged = routingChanged ||
payload.ModuleReady != nil ||
payload.ModuleDisconnected != nil ||
payload.ModuleLeaderRecompute != nil
payload.ModuleDisconnected != nil
err := h.handleEvent(ctx, event)
if err != nil {
h.logger.Error(ctx, errors.WithMessagef(err, "handle event: %s", event.Key()))
@@ -70,8 +68,6 @@ func (h Handler) handleEvent(ctx context.Context, event entity.Event) error {
if err != nil {
return errors.WithMessage(err, "handle module disconnected event")
}
case payload.ModuleLeaderRecompute != nil:
h.subscriptionService.NotifyModuleLeaderRecompute(ctx, *payload.ModuleLeaderRecompute)
default:
return errors.Errorf("unknown event: %v", payload)
}