The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/accesscontrol/dualwrite/batch.go

19 lines
349 B

package dualwrite
// batch will call fn with a batch of T for specified size.
func batch[T any](items []T, batchSize int, fn func([]T) error) error {
count := len(items)
for i := 0; i < count; {
end := i + batchSize
if end > count {
end = count
}
if err := fn(items[i:end]); err != nil {
return err
}
i = end
}
return nil
}