feat(server/desktop): ingest desktop account health reports
Add a POST /desktop/accounts/health-reports endpoint that buffers reports in Redis, dedupes via signature, and publishes change events to a new desktop.account.health RabbitMQ queue. A sink worker drains the queue, and the account service overlays runtime health onto database health when serving desktop accounts. Publish job creation now consults runtime health so a stale DB row no longer blocks publishing once the desktop client reports it healthy. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -116,6 +116,10 @@ func (c *Client) PublishDesktopDispatch(ctx context.Context, routingKey string,
|
||||
return c.publish(ctx, c.cfg.DesktopDispatchExchange, routingKey, body)
|
||||
}
|
||||
|
||||
func (c *Client) PublishDesktopAccountHealth(ctx context.Context, body []byte) error {
|
||||
return c.publish(ctx, c.cfg.DesktopAccountHealthExchange, c.cfg.DesktopAccountHealthRoutingKey, body)
|
||||
}
|
||||
|
||||
// ConsumeDesktopDispatch declares a transient per-process queue bound to the
|
||||
// desktop dispatch topic exchange using bindingKeys, and begins consuming from
|
||||
// it. Every tenant-api instance gets its own queue so every instance sees every
|
||||
@@ -283,6 +287,10 @@ func (c *Client) ConsumeDesktopTaskEvents(consumerName string) (<-chan amqp.Deli
|
||||
return c.consumeFanout(consumerName, c.cfg.DesktopTaskEventExchange)
|
||||
}
|
||||
|
||||
func (c *Client) ConsumeDesktopAccountHealth(consumerName string) (<-chan amqp.Delivery, *amqp.Channel, error) {
|
||||
return c.consume(consumerName, c.cfg.DesktopAccountHealthQueue)
|
||||
}
|
||||
|
||||
func (c *Client) ConsumeTemplateAssistTask(consumerName string) (<-chan amqp.Delivery, *amqp.Channel, error) {
|
||||
return c.consume(consumerName, c.cfg.TemplateAssistQueue)
|
||||
}
|
||||
@@ -685,6 +693,18 @@ func (c *Client) ensureTopology(conn *amqp.Connection) error {
|
||||
return fmt.Errorf("declare rabbitmq exchange %s: %w", c.cfg.DesktopDispatchExchange, err)
|
||||
}
|
||||
|
||||
if err := c.ensureWorkQueue(
|
||||
ch,
|
||||
c.cfg.DesktopAccountHealthExchange,
|
||||
c.cfg.DesktopAccountHealthRoutingKey,
|
||||
c.cfg.DesktopAccountHealthQueue,
|
||||
c.cfg.DesktopAccountHealthDLX,
|
||||
c.cfg.DesktopAccountHealthDLQ,
|
||||
c.cfg.DesktopAccountHealthDLQRouteKey,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.ensureWorkQueue(
|
||||
ch,
|
||||
c.cfg.TemplateAssistExchange,
|
||||
|
||||
Reference in New Issue
Block a user