MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / GetAccountClass

Method GetAccountClass

internal/usage/store.go:97–109  ·  view source on GitHub ↗

GetAccountClass returns the account class for a user. A missing user (no row) resolves to ClassStandard so the metering gate fails toward metering — a real customer must never be silently exempted from billing because of a transient lookup miss. The PK lookup on users is cheap; account class is read

(ctx context.Context, userID string)

Source from the content-addressed store, hash-verified

95// transient lookup miss. The PK lookup on users is cheap; account class is read
96// once per metered message.
97func (s *Store) GetAccountClass(ctx context.Context, userID string) (AccountClass, error) {
98 var class string
99 err := s.pool.QueryRow(ctx,
100 `SELECT account_class FROM users WHERE id = $1`, userID,
101 ).Scan(&class)
102 if err != nil {
103 if errors.Is(err, pgx.ErrNoRows) {
104 return ClassStandard, nil
105 }
106 return ClassStandard, err
107 }
108 return AccountClass(class), nil
109}
110
111func (s *Store) CountAgentsByUser(ctx context.Context, userID string) (int, error) {
112 var count int

Callers 1

RecordAndCheckMethod · 0.80

Implementers 1

Storeinternal/identity/store.go

Calls 3

AccountClassTypeAlias · 0.85
ScanMethod · 0.80
QueryRowMethod · 0.80

Tested by

no test coverage detected