diff --git a/.travis.yml b/.travis.yml index fb65c36..0d22e6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ language: go go: - - 1.7 + - 1.x -before_install: - - go get -t -v ./... +install: + - go get -u github.com/golang/dep/... + - dep ensure script: - go test -v -race -coverprofile=coverage.txt -covermode=atomic diff --git a/cache.go b/cache.go index 60fa534..ff4dc72 100644 --- a/cache.go +++ b/cache.go @@ -4,9 +4,9 @@ import "context" // The Cache interface. If a custom cache is provided, it must implement this interface. type Cache interface { - Get(context.Context, string) (Thunk, bool) - Set(context.Context, string, Thunk) - Delete(context.Context, string) bool + Get(context.Context, interface{}) (Thunk, bool) + Set(context.Context, interface{}, Thunk) + Delete(context.Context, interface{}) bool Clear() } @@ -16,13 +16,13 @@ type Cache interface { type NoCache struct{} // Get is a NOOP -func (c *NoCache) Get(context.Context, string) (Thunk, bool) { return nil, false } +func (c *NoCache) Get(context.Context, interface{}) (Thunk, bool) { return nil, false } // Set is a NOOP -func (c *NoCache) Set(context.Context, string, Thunk) { return } +func (c *NoCache) Set(context.Context, interface{}, Thunk) { return } // Delete is a NOOP -func (c *NoCache) Delete(context.Context, string) bool { return false } +func (c *NoCache) Delete(context.Context, interface{}) bool { return false } // Clear is a NOOP func (c *NoCache) Clear() { return } diff --git a/dataloader.go b/dataloader.go index 6f8a9d2..f695588 100644 --- a/dataloader.go +++ b/dataloader.go @@ -20,8 +20,8 @@ import ( // different access permissions and consider creating a new instance per // web request. type Interface interface { - Load(context.Context, string) Thunk - LoadMany(context.Context, []string) ThunkMany + Load(context.Context, interface{}) Thunk + LoadMany(context.Context, []interface{}) ThunkMany Clear(context.Context, string) Interface ClearAll() Interface Prime(ctx context.Context, key string, value interface{}) Interface @@ -31,7 +31,7 @@ type Interface interface { // It's important that the length of the input keys matches the length of the output results. // // The keys passed to this function are guaranteed to be unique -type BatchFunc func(context.Context, []string) []*Result +type BatchFunc func(context.Context, []interface{}) []*Result // Result is the data structure that a BatchFunc returns. // It contains the resolved data, and any errors that may have occurred while fetching the data. @@ -100,7 +100,7 @@ type ThunkMany func() ([]interface{}, []error) // type used to on input channel type batchRequest struct { - key string + key interface{} channel chan *Result } @@ -191,7 +191,7 @@ func NewBatchedLoader(batchFn BatchFunc, opts ...Option) *Loader { } // Load load/resolves the given key, returning a channel that will contain the value and error -func (l *Loader) Load(originalContext context.Context, key string) Thunk { +func (l *Loader) Load(originalContext context.Context, key interface{}) Thunk { ctx, finish := l.tracer.TraceLoad(originalContext, key) c := make(chan *Result, 1) @@ -267,7 +267,7 @@ func (l *Loader) Load(originalContext context.Context, key string) Thunk { } // LoadMany loads mulitiple keys, returning a thunk (type: ThunkMany) that will resolve the keys passed in. -func (l *Loader) LoadMany(originalContext context.Context, keys []string) ThunkMany { +func (l *Loader) LoadMany(originalContext context.Context, keys []interface{}) ThunkMany { ctx, finish := l.tracer.TraceLoadMany(originalContext, keys) length := len(keys) @@ -386,7 +386,7 @@ func (b *batcher) end() { // execute the batch of all items in queue func (b *batcher) batch(originalContext context.Context) { - var keys []string + var keys []interface{} var reqs []*batchRequest var items []*Result var panicErr interface{} diff --git a/dataloader_test.go b/dataloader_test.go index eddd48f..134fe64 100644 --- a/dataloader_test.go +++ b/dataloader_test.go @@ -81,7 +81,7 @@ func TestLoader(t *testing.T) { t.Parallel() errorLoader, _ := ErrorLoader(0) ctx := context.Background() - future := errorLoader.LoadMany(ctx, []string{"1", "2", "3"}) + future := errorLoader.LoadMany(ctx, []interface{}{"1", "2", "3"}) _, err := future() if len(err) != 3 { t.Error("LoadMany didn't return right number of errors") @@ -90,13 +90,13 @@ func TestLoader(t *testing.T) { t.Run("test LoadMany returns len(errors) == len(keys)", func(t *testing.T) { t.Parallel() - loader, _ := OneErrorLoader(0) + loader, _ := OneErrorLoader(3) ctx := context.Background() - future := loader.LoadMany(ctx, []string{"1", "2", "3"}) + future := loader.LoadMany(ctx, []interface{}{"1", "2", "3"}) _, err := future() + log.Printf("errs: %#v", err) if len(err) != 3 { - t.Error("LoadMany didn't return right number of errors (should match size of input)") - return + t.Errorf("LoadMany didn't return right number of errors (should match size of input)") } if err[0] == nil { @@ -112,7 +112,7 @@ func TestLoader(t *testing.T) { t.Parallel() identityLoader, _ := IDLoader(0) ctx := context.Background() - future := identityLoader.LoadMany(ctx, []string{"1", "2", "3"}) + future := identityLoader.LoadMany(ctx, []interface{}{"1", "2", "3"}) go future() go future() }) @@ -127,7 +127,7 @@ func TestLoader(t *testing.T) { }() panicLoader, _ := PanicLoader(0) ctx := context.Background() - future := panicLoader.LoadMany(ctx, []string{"1"}) + future := panicLoader.LoadMany(ctx, []interface{}{"1"}) _, errs := future() if len(errs) < 1 || errs[0].Error() != "Panic received in batch function: Programming error" { t.Error("Panic was not propagated as an error.") @@ -138,7 +138,7 @@ func TestLoader(t *testing.T) { t.Parallel() identityLoader, _ := IDLoader(0) ctx := context.Background() - future := identityLoader.LoadMany(ctx, []string{"1", "2", "3"}) + future := identityLoader.LoadMany(ctx, []interface{}{"1", "2", "3"}) results, _ := future() if results[0].(string) != "1" || results[1].(string) != "2" || results[2].(string) != "3" { t.Error("loadmany didn't return the right value") @@ -162,8 +162,8 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner := []string{"1", "2"} - expected := [][]string{inner} + inner := []interface{}{"1", "2"} + expected := [][]interface{}{inner} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not call batchFn in right order. Expected %#v, got %#v", expected, calls) } @@ -176,7 +176,7 @@ func TestLoader(t *testing.T) { n := 10 reqs := []Thunk{} - keys := []string{} + keys := []interface{}{} for i := 0; i < n; i++ { key := strconv.Itoa(i) reqs = append(reqs, faultyLoader.Load(ctx, key)) @@ -215,9 +215,9 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner1 := []string{"1", "2"} - inner2 := []string{"3"} - expected := [][]string{inner1, inner2} + inner1 := []interface{}{"1", "2"} + inner2 := []interface{}{"3"} + expected := [][]interface{}{inner1, inner2} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not respect max batch size. Expected %#v, got %#v", expected, calls) } @@ -240,8 +240,8 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner := []string{"1"} - expected := [][]string{inner} + inner := []interface{}{"1"} + expected := [][]interface{}{inner} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not respect max batch size. Expected %#v, got %#v", expected, calls) } @@ -265,8 +265,8 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner := []string{"1"} - expected := [][]string{inner} + inner := []interface{}{"1"} + expected := [][]interface{}{inner} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not respect max batch size. Expected %#v, got %#v", expected, calls) } @@ -300,8 +300,8 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner := []string{"1", "A"} - expected := [][]string{inner} + inner := []interface{}{"1", "A"} + expected := [][]interface{}{inner} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not respect max batch size. Expected %#v, got %#v", expected, calls) } @@ -328,8 +328,8 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner := []string{"1"} - expected := [][]string{inner} + inner := []interface{}{"1"} + expected := [][]interface{}{inner} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not batch queries. Expected %#v, got %#v", expected, calls) } @@ -366,8 +366,8 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner := []string{"1", "A", "B"} - expected := [][]string{inner} + inner := []interface{}{"1", "A", "B"} + expected := [][]interface{}{inner} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not respect max batch size. Expected %#v, got %#v", expected, calls) } @@ -400,8 +400,8 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner := []string{"1", "A", "B"} - expected := [][]string{inner} + inner := []interface{}{"1", "A", "B"} + expected := [][]interface{}{inner} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not respect max batch size. Expected %#v, got %#v", expected, calls) } @@ -432,8 +432,8 @@ func TestLoader(t *testing.T) { } calls := *loadCalls - inner := []string{"1", "A", "B"} - expected := [][]string{inner} + inner := []interface{}{"1", "A", "B"} + expected := [][]interface{}{inner} if !reflect.DeepEqual(calls, expected) { t.Errorf("did not respect max batch size. Expected %#v, got %#v", expected, calls) } @@ -442,10 +442,10 @@ func TestLoader(t *testing.T) { } // test helpers -func IDLoader(max int) (*Loader, *[][]string) { +func IDLoader(max int) (*Loader, *[][]interface{}) { var mu sync.Mutex - var loadCalls [][]string - identityLoader := NewBatchedLoader(func(_ context.Context, keys []string) []*Result { + var loadCalls [][]interface{} + identityLoader := NewBatchedLoader(func(_ context.Context, keys []interface{}) []*Result { var results []*Result mu.Lock() loadCalls = append(loadCalls, keys) @@ -457,10 +457,10 @@ func IDLoader(max int) (*Loader, *[][]string) { }, WithBatchCapacity(max)) return identityLoader, &loadCalls } -func BatchOnlyLoader(max int) (*Loader, *[][]string) { +func BatchOnlyLoader(max int) (*Loader, *[][]interface{}) { var mu sync.Mutex - var loadCalls [][]string - identityLoader := NewBatchedLoader(func(_ context.Context, keys []string) []*Result { + var loadCalls [][]interface{} + identityLoader := NewBatchedLoader(func(_ context.Context, keys []interface{}) []*Result { var results []*Result mu.Lock() loadCalls = append(loadCalls, keys) @@ -472,10 +472,10 @@ func BatchOnlyLoader(max int) (*Loader, *[][]string) { }, WithBatchCapacity(max), WithClearCacheOnBatch()) return identityLoader, &loadCalls } -func ErrorLoader(max int) (*Loader, *[][]string) { +func ErrorLoader(max int) (*Loader, *[][]interface{}) { var mu sync.Mutex - var loadCalls [][]string - identityLoader := NewBatchedLoader(func(_ context.Context, keys []string) []*Result { + var loadCalls [][]interface{} + identityLoader := NewBatchedLoader(func(_ context.Context, keys []interface{}) []*Result { var results []*Result mu.Lock() loadCalls = append(loadCalls, keys) @@ -487,11 +487,11 @@ func ErrorLoader(max int) (*Loader, *[][]string) { }, WithBatchCapacity(max)) return identityLoader, &loadCalls } -func OneErrorLoader(max int) (*Loader, *[][]string) { +func OneErrorLoader(max int) (*Loader, *[][]interface{}) { var mu sync.Mutex - var loadCalls [][]string - identityLoader := NewBatchedLoader(func(_ context.Context, keys []string) []*Result { - var results []*Result + var loadCalls [][]interface{} + identityLoader := NewBatchedLoader(func(_ context.Context, keys []interface{}) []*Result { + results := make([]*Result, max, max) mu.Lock() loadCalls = append(loadCalls, keys) mu.Unlock() @@ -500,23 +500,23 @@ func OneErrorLoader(max int) (*Loader, *[][]string) { if i == 0 { err = errors.New("always error on the first key") } - results = append(results, &Result{key, err}) + results[i] = &Result{key, err} } return results }, WithBatchCapacity(max)) return identityLoader, &loadCalls } -func PanicLoader(max int) (*Loader, *[][]string) { - var loadCalls [][]string - panicLoader := NewBatchedLoader(func(_ context.Context, keys []string) []*Result { +func PanicLoader(max int) (*Loader, *[][]interface{}) { + var loadCalls [][]interface{} + panicLoader := NewBatchedLoader(func(_ context.Context, keys []interface{}) []*Result { panic("Programming error") }, WithBatchCapacity(max), withSilentLogger()) return panicLoader, &loadCalls } -func BadLoader(max int) (*Loader, *[][]string) { +func BadLoader(max int) (*Loader, *[][]interface{}) { var mu sync.Mutex - var loadCalls [][]string - identityLoader := NewBatchedLoader(func(_ context.Context, keys []string) []*Result { + var loadCalls [][]interface{} + identityLoader := NewBatchedLoader(func(_ context.Context, keys []interface{}) []*Result { var results []*Result mu.Lock() loadCalls = append(loadCalls, keys) @@ -526,11 +526,11 @@ func BadLoader(max int) (*Loader, *[][]string) { }, WithBatchCapacity(max)) return identityLoader, &loadCalls } -func NoCacheLoader(max int) (*Loader, *[][]string) { +func NoCacheLoader(max int) (*Loader, *[][]interface{}) { var mu sync.Mutex - var loadCalls [][]string + var loadCalls [][]interface{} cache := &NoCache{} - identityLoader := NewBatchedLoader(func(_ context.Context, keys []string) []*Result { + identityLoader := NewBatchedLoader(func(_ context.Context, keys []interface{}) []*Result { var results []*Result mu.Lock() loadCalls = append(loadCalls, keys) @@ -544,11 +544,11 @@ func NoCacheLoader(max int) (*Loader, *[][]string) { } // FaultyLoader gives len(keys)-1 results. -func FaultyLoader() (*Loader, *[][]string) { +func FaultyLoader() (*Loader, *[][]interface{}) { var mu sync.Mutex - var loadCalls [][]string + var loadCalls [][]interface{} - loader := NewBatchedLoader(func(_ context.Context, keys []string) []*Result { + loader := NewBatchedLoader(func(_ context.Context, keys []interface{}) []*Result { var results []*Result mu.Lock() loadCalls = append(loadCalls, keys) @@ -573,7 +573,7 @@ func FaultyLoader() (*Loader, *[][]string) { /////////////////////////////////////////////////// var a = &Avg{} -func batchIdentity(_ context.Context, keys []string) (results []*Result) { +func batchIdentity(_ context.Context, keys []interface{}) (results []*Result) { a.Add(len(keys)) for _, key := range keys { results = append(results, &Result{key, nil}) diff --git a/example/lru-cache/golang-lru.go b/example/lru-cache/golang-lru.go index 1eda737..a3de398 100644 --- a/example/lru-cache/golang-lru.go +++ b/example/lru-cache/golang-lru.go @@ -16,7 +16,7 @@ type Cache struct { } // Get gets an item from the cache -func (c *Cache) Get(_ context.Context, key string) (dataloader.Thunk, bool) { +func (c *Cache) Get(_ context.Context, key interface{}) (dataloader.Thunk, bool) { v, ok := c.ARCCache.Get(key) if ok { return v.(dataloader.Thunk), ok @@ -25,12 +25,12 @@ func (c *Cache) Get(_ context.Context, key string) (dataloader.Thunk, bool) { } // Set sets an item in the cache -func (c *Cache) Set(_ context.Context, key string, value dataloader.Thunk) { +func (c *Cache) Set(_ context.Context, key interface{}, value dataloader.Thunk) { c.ARCCache.Add(key, value) } // Delete deletes an item in the cache -func (c *Cache) Delete(_ context.Context, key string) bool { +func (c *Cache) Delete(_ context.Context, key interface{}) bool { if c.ARCCache.Contains(key) { c.ARCCache.Remove(key) return true @@ -58,7 +58,7 @@ func main() { fmt.Printf("identity: %s\n", result) } -func batchFunc(_ context.Context, keys []string) []*dataloader.Result { +func batchFunc(_ context.Context, keys []interface{}) []*dataloader.Result { var results []*dataloader.Result // do some pretend work to resolve keys for _, key := range keys { diff --git a/example/no-cache/no-cache.go b/example/no-cache/no-cache.go index 025ac34..dbb91ac 100644 --- a/example/no-cache/no-cache.go +++ b/example/no-cache/no-cache.go @@ -20,7 +20,7 @@ func main() { fmt.Printf("identity: %s\n", result) } -func batchFunc(_ context.Context, keys []string) []*dataloader.Result { +func batchFunc(_ context.Context, keys []interface{}) []*dataloader.Result { var results []*dataloader.Result // do some pretend work to resolve keys for _, key := range keys { diff --git a/example/ttl-cache/go-cache.go b/example/ttl-cache/go-cache.go index 9d347b3..005a985 100644 --- a/example/ttl-cache/go-cache.go +++ b/example/ttl-cache/go-cache.go @@ -17,8 +17,8 @@ type Cache struct { } // Get gets a value from the cache -func (c *Cache) Get(_ context.Context, key string) (dataloader.Thunk, bool) { - v, ok := c.c.Get(key) +func (c *Cache) Get(_ context.Context, key interface{}) (dataloader.Thunk, bool) { + v, ok := c.c.Get(key.(string)) if ok { return v.(dataloader.Thunk), ok } @@ -26,14 +26,14 @@ func (c *Cache) Get(_ context.Context, key string) (dataloader.Thunk, bool) { } // Set sets a value in the cache -func (c *Cache) Set(_ context.Context, key string, value dataloader.Thunk) { - c.c.Set(key, value, 0) +func (c *Cache) Set(_ context.Context, key interface{}, value dataloader.Thunk) { + c.c.Set(key.(string), value, 0) } // Delete deletes and item in the cache -func (c *Cache) Delete(_ context.Context, key string) bool { - if _, found := c.c.Get(key); found { - c.c.Delete(key) +func (c *Cache) Delete(_ context.Context, key interface{}) bool { + if _, found := c.c.Get(key.(string)); found { + c.c.Delete(key.(string)) return true } return false @@ -59,7 +59,7 @@ func main() { fmt.Printf("identity: %s\n", result) } -func batchFunc(_ context.Context, keys []string) []*dataloader.Result { +func batchFunc(_ context.Context, keys []interface{}) []*dataloader.Result { var results []*dataloader.Result // do some pretend work to resolve keys for _, key := range keys { diff --git a/inMemoryCache.go b/inMemoryCache.go index f58ee9e..9d083fd 100644 --- a/inMemoryCache.go +++ b/inMemoryCache.go @@ -13,20 +13,20 @@ import ( // for the life of an http request) but it not well suited // for long lived cached items. type InMemoryCache struct { - items map[string]Thunk + items map[interface{}]Thunk mu sync.RWMutex } // NewCache constructs a new InMemoryCache func NewCache() *InMemoryCache { - items := make(map[string]Thunk) + items := make(map[interface{}]Thunk) return &InMemoryCache{ items: items, } } // Set sets the `value` at `key` in the cache -func (c *InMemoryCache) Set(_ context.Context, key string, value Thunk) { +func (c *InMemoryCache) Set(_ context.Context, key interface{}, value Thunk) { c.mu.Lock() c.items[key] = value c.mu.Unlock() @@ -34,7 +34,7 @@ func (c *InMemoryCache) Set(_ context.Context, key string, value Thunk) { // Get gets the value at `key` if it exsits, returns value (or nil) and bool // indicating of value was found -func (c *InMemoryCache) Get(_ context.Context, key string) (Thunk, bool) { +func (c *InMemoryCache) Get(_ context.Context, key interface{}) (Thunk, bool) { c.mu.RLock() defer c.mu.RUnlock() @@ -47,7 +47,7 @@ func (c *InMemoryCache) Get(_ context.Context, key string) (Thunk, bool) { } // Delete deletes item at `key` from cache -func (c *InMemoryCache) Delete(_ context.Context, key string) bool { +func (c *InMemoryCache) Delete(_ context.Context, key interface{}) bool { if _, found := c.Get(key); found { c.mu.Lock() defer c.mu.Unlock() @@ -60,6 +60,6 @@ func (c *InMemoryCache) Delete(_ context.Context, key string) bool { // Clear clears the entire cache func (c *InMemoryCache) Clear() { c.mu.Lock() - c.items = map[string]Thunk{} + c.items = map[interface{}]Thunk{} c.mu.Unlock() } diff --git a/inMemoryCache_go19.go b/inMemoryCache_go19.go index 3931ba5..af5916a 100644 --- a/inMemoryCache_go19.go +++ b/inMemoryCache_go19.go @@ -24,13 +24,13 @@ func NewCache() *InMemoryCache { } // Set sets the `value` at `key` in the cache -func (c *InMemoryCache) Set(_ context.Context, key string, value Thunk) { +func (c *InMemoryCache) Set(_ context.Context, key interface{}, value Thunk) { c.items.Store(key, value) } // Get gets the value at `key` if it exsits, returns value (or nil) and bool // indicating of value was found -func (c *InMemoryCache) Get(_ context.Context, key string) (Thunk, bool) { +func (c *InMemoryCache) Get(_ context.Context, key interface{}) (Thunk, bool) { item, found := c.items.Load(key) if !found { return nil, false @@ -40,7 +40,7 @@ func (c *InMemoryCache) Get(_ context.Context, key string) (Thunk, bool) { } // Delete deletes item at `key` from cache -func (c *InMemoryCache) Delete(_ context.Context, key string) bool { +func (c *InMemoryCache) Delete(_ context.Context, key interface{}) bool { if _, found := c.items.Load(key); found { c.items.Delete(key) return true diff --git a/trace.go b/trace.go index adfae18..f76fbb5 100644 --- a/trace.go +++ b/trace.go @@ -13,18 +13,18 @@ type TraceBatchFinishFunc func([]*Result) // Tracer is an interface that may be used to implement tracing. type Tracer interface { // TraceLoad will trace the calls to Load - TraceLoad(ctx context.Context, key string) (context.Context, TraceLoadFinishFunc) + TraceLoad(ctx context.Context, key interface{}) (context.Context, TraceLoadFinishFunc) // TraceLoadMany will trace the calls to LoadMany - TraceLoadMany(ctx context.Context, keys []string) (context.Context, TraceLoadManyFinishFunc) + TraceLoadMany(ctx context.Context, keys []interface{}) (context.Context, TraceLoadManyFinishFunc) // TraceBatch will trace data loader batches - TraceBatch(ctx context.Context, keys []string) (context.Context, TraceBatchFinishFunc) + TraceBatch(ctx context.Context, keys []interface{}) (context.Context, TraceBatchFinishFunc) } // OpenTracing Tracer implements a tracer that can be used with the Open Tracing standard. type OpenTracingTracer struct{} // TraceLoad will trace a call to dataloader.LoadMany with Open Tracing -func (OpenTracingTracer) TraceLoad(ctx context.Context, key string) (context.Context, TraceLoadFinishFunc) { +func (OpenTracingTracer) TraceLoad(ctx context.Context, key interface{}) (context.Context, TraceLoadFinishFunc) { span, spanCtx := opentracing.StartSpanFromContext(ctx, "Dataloader: load") span.SetTag("dataloader.key", key) @@ -36,7 +36,7 @@ func (OpenTracingTracer) TraceLoad(ctx context.Context, key string) (context.Con } // TraceLoadMany will trace a call to dataloader.LoadMany with Open Tracing -func (OpenTracingTracer) TraceLoadMany(ctx context.Context, keys []string) (context.Context, TraceLoadManyFinishFunc) { +func (OpenTracingTracer) TraceLoadMany(ctx context.Context, keys []interface{}) (context.Context, TraceLoadManyFinishFunc) { span, spanCtx := opentracing.StartSpanFromContext(ctx, "Dataloader: loadmany") span.SetTag("dataloader.keys", keys) @@ -48,7 +48,7 @@ func (OpenTracingTracer) TraceLoadMany(ctx context.Context, keys []string) (cont } // TraceBatch will trace a call to dataloader.LoadMany with Open Tracing -func (OpenTracingTracer) TraceBatch(ctx context.Context, keys []string) (context.Context, TraceBatchFinishFunc) { +func (OpenTracingTracer) TraceBatch(ctx context.Context, keys []interface{}) (context.Context, TraceBatchFinishFunc) { span, spanCtx := opentracing.StartSpanFromContext(ctx, "Dataloader: batch") span.SetTag("dataloader.keys", keys) @@ -63,16 +63,16 @@ func (OpenTracingTracer) TraceBatch(ctx context.Context, keys []string) (context type NoopTracer struct{} // TraceLoad is a noop function -func (NoopTracer) TraceLoad(ctx context.Context, key string) (context.Context, TraceLoadFinishFunc) { +func (NoopTracer) TraceLoad(ctx context.Context, key interface{}) (context.Context, TraceLoadFinishFunc) { return ctx, func(Thunk) {} } // TraceLoadMany is a noop function -func (NoopTracer) TraceLoadMany(ctx context.Context, keys []string) (context.Context, TraceLoadManyFinishFunc) { +func (NoopTracer) TraceLoadMany(ctx context.Context, keys []interface{}) (context.Context, TraceLoadManyFinishFunc) { return ctx, func(ThunkMany) {} } // TraceBatch is a noop function -func (NoopTracer) TraceBatch(ctx context.Context, keys []string) (context.Context, TraceBatchFinishFunc) { +func (NoopTracer) TraceBatch(ctx context.Context, keys []interface{}) (context.Context, TraceBatchFinishFunc) { return ctx, func(result []*Result) {} }