Skip to content

feat(utils): add VisitAllBreakable function#58

Open
AmadeusK525 wants to merge 1 commit intoVictoriaMetrics:masterfrom
AmadeusK525:feat/add-breakable-visitall
Open

feat(utils): add VisitAllBreakable function#58
AmadeusK525 wants to merge 1 commit intoVictoriaMetrics:masterfrom
AmadeusK525:feat/add-breakable-visitall

Conversation

@AmadeusK525
Copy link

Useful for early breaks from the loop

Useful for early breaks from the loop
@makasim
Copy link
Member

makasim commented Jan 12, 2026

Could you please provide some practical cases where this function could be helpful?

@AmadeusK525
Copy link
Author

func hasOverTimeFunc(expr metricsql.Expr) bool {
	hasFunc := false
	metricsql.VisitAllBreakable(expr, func(node metricsql.Expr) {
		if fn, ok := node.(*metricsql.FuncExpr); ok {
			if strings.HasSuffix(fn.Name, "_over_time") {
				hasFunc = true
				return false
			}
		}
		return true
	})
	return hasFunc
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants