fix(enterprise/coderd): propagate license events over Postgres pubsub when NATS is in use (#26536)

Co-authored-by: Mux <mux@coder.com>
This commit is contained in:
Callum Styan
2026-06-23 09:58:45 -07:00
committed by GitHub
co-authored by Mux
parent c7ddcce62c
commit d104d0dcb3
2 changed files with 22 additions and 5 deletions
+6 -2
View File
@@ -1354,7 +1354,8 @@ func (api *API) runEntitlementsLoop(ctx context.Context) {
// the system will eventually recover as replicas timeout
// if their heartbeats stop. The best effort just tries to update the
// UI faster if it succeeds.
_ = api.Pubsub.Publish(PubsubEventLicenses, []byte("going away"))
// Postgres pubsub; see PubsubEventLicenses.
_ = api.ReplicaSyncPubsub.Publish(PubsubEventLicenses, []byte("going away"))
}()
for {
select {
@@ -1364,7 +1365,10 @@ func (api *API) runEntitlementsLoop(ctx context.Context) {
// pass
}
if !subscribed {
cancel, err := api.Pubsub.Subscribe(PubsubEventLicenses, func(_ context.Context, _ []byte) {
// Postgres pubsub; see PubsubEventLicenses. ReplicaSyncPubsub is
// always set in enterprise startup (replicasync.New requires it when
// the API is constructed), so it is safe to use directly here.
cancel, err := api.ReplicaSyncPubsub.Subscribe(PubsubEventLicenses, func(_ context.Context, _ []byte) {
// don't block. If the channel is full, drop the event, as there is a resync
// scheduled already.
select {