func (b *listSomeEntitiesResponse_SomeEntitySliceBatch) keyIndex(l *ListSomeEntitiesResponse_SomeEntitySliceLoader, key string) int {
	for i, existingKey := range b.keys {
		if key == existingKey {
			return i
		}
	}
	pos := len(b.keys)
	b.keys = append(b.keys, key)
	if pos == 0 {
		go b.startTimer(l)
	}
	if l.maxBatch != 0 && pos >= l.maxBatch-1 {
		if !b.closing {
			b.closing = true
			l.batch = nil
			go b.end(l)
		}
	}
	return pos
}
keyIndex will return the location of the key in the batch, if its not found
it will add the key to the batch
package loaders
import (
	"sync"
	"time"
	"github.com/EGT-Ukraine/go2gql/example/proto"
)
type ListSomeEntitiesResponse_SomeEntitySliceLoader struct {
	fetch func(keys []string) ([][]*proto.ListSomeEntitiesResponse_SomeEntity, []error)
	wait time.Duration
	maxBatch int
	cache map[string][]*proto.ListSomeEntitiesResponse_SomeEntity
	batch *listSomeEntitiesResponse_SomeEntitySliceBatch
	mu sync.Mutex
}
type listSomeEntitiesResponse_SomeEntitySliceBatch struct {
	keys    []string
	data    [][]*proto.ListSomeEntitiesResponse_SomeEntity
	error   []error
	closing bool
	done    chan struct{}
}
func (l *ListSomeEntitiesResponse_SomeEntitySliceLoader) Load(key string) ([]*proto.ListSomeEntitiesResponse_SomeEntity, error) {
	return l.LoadThunk(key)()
}
func (l *ListSomeEntitiesResponse_SomeEntitySliceLoader) LoadThunk(key string) func() ([]*proto.ListSomeEntitiesResponse_SomeEntity, error) {
	l.mu.Lock()
	if it, ok := l.cache[key]; ok {
		l.mu.Unlock()
		return func() ([]*proto.ListSomeEntitiesResponse_SomeEntity, error) {
			return it, nil
		}
	}
	if l.batch == nil {
		l.batch = &listSomeEntitiesResponse_SomeEntitySliceBatch{done: make(chan struct{})}
	}
	batch := l.batch
	pos := batch.keyIndex(l, key)
	l.mu.Unlock()
	return func() ([]*proto.ListSomeEntitiesResponse_SomeEntity, error) {
		<-batch.done
		var data []*proto.ListSomeEntitiesResponse_SomeEntity
		if pos < len(batch.data) {
			data = batch.data[pos]
		}
		var err error
		if len(batch.error) == 1 {
			err = batch.error[0]
		} else if batch.error != nil {
			err = batch.error[pos]
		}
		if err == nil {
			l.mu.Lock()
			l.unsafeSet(key, data)
			l.mu.Unlock()
		}
		return data, err
	}
}
func (l *ListSomeEntitiesResponse_SomeEntitySliceLoader) LoadAll(keys []string) ([][]*proto.ListSomeEntitiesResponse_SomeEntity, []error) {
	results := make([]func() ([]*proto.ListSomeEntitiesResponse_SomeEntity, error), len(keys))
	for i, key := range keys {
		results[i] = l.LoadThunk(key)
	}
	listSomeEntitiesResponse_SomeEntitys := make([][]*proto.ListSomeEntitiesResponse_SomeEntity, len(keys))
	errors := make([]error, len(keys))
	for i, thunk := range results {
		listSomeEntitiesResponse_SomeEntitys[i], errors[i] = thunk()
	}
	return listSomeEntitiesResponse_SomeEntitys, errors
}
func (l *ListSomeEntitiesResponse_SomeEntitySliceLoader) LoadAllThunk(keys []string) func() ([][]*proto.ListSomeEntitiesResponse_SomeEntity, []error) {
	results := make([]func() ([]*proto.ListSomeEntitiesResponse_SomeEntity, error), len(keys))
	for i, key := range keys {
		results[i] = l.LoadThunk(key)
	}
	return func() ([][]*proto.ListSomeEntitiesResponse_SomeEntity, []error) {
		listSomeEntitiesResponse_SomeEntitys := make([][]*proto.ListSomeEntitiesResponse_SomeEntity, len(keys))
		errors := make([]error, len(keys))
		for i, thunk := range results {
			listSomeEntitiesResponse_SomeEntitys[i], errors[i] = thunk()
		}
		return listSomeEntitiesResponse_SomeEntitys, errors
	}
}
func (l *ListSomeEntitiesResponse_SomeEntitySliceLoader) Prime(key string, value []*proto.ListSomeEntitiesResponse_SomeEntity) bool {
	l.mu.Lock()
	var found bool
	if _, found = l.cache[key]; !found {
		l.unsafeSet(key, value)
	}
	l.mu.Unlock()
	return !found
}
func (l *ListSomeEntitiesResponse_SomeEntitySliceLoader) Clear(key string) {
	l.mu.Lock()
	delete(l.cache, key)
	l.mu.Unlock()
}
func (l *ListSomeEntitiesResponse_SomeEntitySliceLoader) unsafeSet(key string, value []*proto.ListSomeEntitiesResponse_SomeEntity) {
	if l.cache == nil {
		l.cache = map[string][]*proto.ListSomeEntitiesResponse_SomeEntity{}
	}
	l.cache[key] = value
}