You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: bulk.go
    path of file: ./repos/grafana/pkg/services/sqlstore
    
    the code of the file until where you have to start completion: package sqlstore

import (
	"fmt"
	"reflect"

	"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
)

const DefaultBatchSize = 1000

type BulkOpSettings struct 
    
func InBatches(items any, opts BulkOpSettings, fn func(batch any) error) error {
	opts = normalizeBulkSettings(opts)
	slice := reflect.Indirect(reflect.ValueOf(items))
	if slice.Kind() != reflect.Slice {
		return fmt.Errorf("need a slice of objects in order to batch")
	}

	for i := 0; i < slice.Len(); i += opts.BatchSize {
		end := i + opts.BatchSize
		if end > slice.Len() {
			end = slice.Len()
		}

		chunk := slice.Slice(i, end).Interface()

		if err := fn(chunk); err != nil {
			return err
		}
	}
	return nil
}