MCPcopy Create free account
hub / github.com/github/gh-aw / extractRateLimitConfig

Method extractRateLimitConfig

pkg/workflow/role_checks.go:216–299  ·  view source on GitHub ↗

extractRateLimitConfig extracts the user-rate-limit config from frontmatter.

(frontmatter map[string]any)

Source from the content-addressed store, hash-verified

214
215// extractRateLimitConfig extracts the user-rate-limit config from frontmatter.
216func (c *Compiler) extractRateLimitConfig(frontmatter map[string]any) *RateLimitConfig {
217 rateLimitValue, exists := frontmatter["user-rate-limit"]
218
219 if exists && rateLimitValue != nil {
220 switch v := rateLimitValue.(type) {
221 case map[string]any:
222 config := &RateLimitConfig{}
223
224 // Extract max-runs-per-window (default: 5)
225 maxValue, ok := v["max-runs-per-window"]
226 if !ok {
227 maxValue, ok = v["max-runs"]
228 }
229 if !ok {
230 maxValue, ok = v["max"] // legacy compatibility
231 }
232 if ok {
233 switch max := maxValue.(type) {
234 case int:
235 config.Max = max
236 case int64:
237 config.Max = int(max)
238 case uint64:
239 config.Max = int(max)
240 case float64:
241 config.Max = int(max)
242 }
243 }
244
245 // Extract window (default: 60 minutes)
246 if windowValue, ok := v["window"]; ok {
247 switch window := windowValue.(type) {
248 case int:
249 config.Window = window
250 case int64:
251 config.Window = int(window)
252 case uint64:
253 config.Window = int(window)
254 case float64:
255 config.Window = int(window)
256 }
257 }
258
259 // Extract events
260 if eventsValue, ok := v["events"]; ok {
261 switch events := eventsValue.(type) {
262 case []any:
263 config.Events = parseStringSliceAny(events, nil)
264 case []string:
265 config.Events = events
266 case string:
267 config.Events = []string{events}
268 }
269 } else {
270 // If events not specified, infer from the 'on:' section of frontmatter
271 config.Events = c.inferEventsFromTriggers(frontmatter)
272 if len(config.Events) > 0 {
273 roleLog.Printf("Inferred events from workflow triggers: %v", config.Events)

Callers 2

Calls 4

parseStringSliceAnyFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by 1