MCPcopy Create free account
hub / github.com/diillson/chatcli / extractClientID

Method extractClientID

server/rate_limiter.go:130–140  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

128}
129
130func (rl *PerClientRateLimiter) extractClientID(ctx context.Context) string {
131 // Prefer user identity from JWT/auth context
132 if user := UserFromContext(ctx); user != nil {
133 return user.Subject
134 }
135 // Fall back to peer address
136 if p, ok := peer.FromContext(ctx); ok {
137 return p.Addr.String()
138 }
139 return "unknown"
140}
141
142func (rl *PerClientRateLimiter) getLimiter(clientID string) *rate.Limiter {
143 rl.mu.Lock()

Callers 2

UnaryInterceptorMethod · 0.95
StreamInterceptorMethod · 0.95

Calls 2

UserFromContextFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected