mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 17:42:35 +08:00

* Rewrite zanzana collector to fetch all available pages * Register access control as a background service * If zanzana is enabled we run Syncs and start Reconciliation job * Update pkg/services/authz/zanzana/client/client.go Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com> * Use server lock when doing performing reconciliation
20 lines
349 B
Go
20 lines
349 B
Go
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
|
|
}
|