AISeatsHeartbeat returns a HeartbeatFunc that queries the active AI seat count and emits it as an HBAISeats heartbeat event.
(db database.Store)
| 18 | // AISeatsHeartbeat returns a HeartbeatFunc that queries the active |
| 19 | // AI seat count and emits it as an HBAISeats heartbeat event. |
| 20 | func AISeatsHeartbeat(db database.Store) HeartbeatFunc { |
| 21 | return func(ctx context.Context) (usagetypes.HeartbeatEvent, error) { |
| 22 | //nolint:gocritic // We are a publisher in this function |
| 23 | ctx = dbauthz.AsUsagePublisher(ctx) |
| 24 | count, err := db.GetActiveAISeatCount(ctx) |
| 25 | if err != nil { |
| 26 | return nil, xerrors.Errorf("get active AI seat count: %w", err) |
| 27 | } |
| 28 | |
| 29 | return usagetypes.HBAISeats{Count: count}, nil |
| 30 | } |
| 31 | } |