MCPcopy Index your code
hub / github.com/coder/coder / AISeatsHeartbeat

Function AISeatsHeartbeat

enterprise/coderd/usage/heartbeats.go:20–31  ·  view source on GitHub ↗

AISeatsHeartbeat returns a HeartbeatFunc that queries the active AI seat count and emits it as an HBAISeats heartbeat event.

(db database.Store)

Source from the content-addressed store, hash-verified

18// AISeatsHeartbeat returns a HeartbeatFunc that queries the active
19// AI seat count and emits it as an HBAISeats heartbeat event.
20func 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}

Callers 2

TestAISeatsHeartbeatFunction · 0.92
ServerMethod · 0.92

Calls 3

AsUsagePublisherFunction · 0.92
GetActiveAISeatCountMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

TestAISeatsHeartbeatFunction · 0.74