|
1 | 1 | # DataLoader |
2 | | -[](https://godoc.org/github.com/nicksrandall/dataloader) |
3 | | -[](https://travis-ci.org/nicksrandall/dataloader) |
4 | | -[](https://codecov.io/gh/nicksrandall/dataloader) |
| 2 | +[](https://godoc.org/github.com/graph-gophers/dataloader) |
| 3 | +[](https://travis-ci.org/graph-gophers/dataloader) |
| 4 | +[](https://codecov.io/gh/graph-gophers/dataloader) |
5 | 5 |
|
6 | 6 | This is an implementation of [Facebook's DataLoader](https://github.com/facebook/dataloader) in Golang. |
7 | 7 |
|
8 | | -## Status |
9 | | -This project is a work in progress. Feedback is encouraged. |
10 | | - |
11 | 8 | ## Install |
12 | | -`go get -u gopkg.in/nicksrandall/dataloader.v5` |
| 9 | +`go get -u github.com/graph-gophers/dataloader` |
13 | 10 |
|
14 | 11 | ## Usage |
15 | 12 | ```go |
@@ -40,95 +37,6 @@ if err != nil { |
40 | 37 | log.Printf("value: %#v", result) |
41 | 38 | ``` |
42 | 39 |
|
43 | | -## Upgrade from v1 to v2 |
44 | | -The only difference between v1 and v2 is that we added use of [context](https://golang.org/pkg/context). |
45 | | - |
46 | | -```diff |
47 | | -- loader.Load(key string) Thunk |
48 | | -+ loader.Load(ctx context.Context, key string) Thunk |
49 | | -- loader.LoadMany(keys []string) ThunkMany |
50 | | -+ loader.LoadMany(ctx context.Context, keys []string) ThunkMany |
51 | | -``` |
52 | | - |
53 | | -```diff |
54 | | -- type BatchFunc func([]string) []*Result |
55 | | -+ type BatchFunc func(context.Context, []string) []*Result |
56 | | -``` |
57 | | - |
58 | | -## Upgrade from v2 to v3 |
59 | | -```diff |
60 | | -// dataloader.Interface as added context.Context to methods |
61 | | -- loader.Prime(key string, value interface{}) Interface |
62 | | -+ loader.Prime(ctx context.Context, key string, value interface{}) Interface |
63 | | -- loader.Clear(key string) Interface |
64 | | -+ loader.Clear(ctx context.Context, key string) Interface |
65 | | -``` |
66 | | - |
67 | | -```diff |
68 | | -// cache interface as added context.Context to methods |
69 | | -type Cache interface { |
70 | | -- Get(string) (Thunk, bool) |
71 | | -+ Get(context.Context, string) (Thunk, bool) |
72 | | -- Set(string, Thunk) |
73 | | -+ Set(context.Context, string, Thunk) |
74 | | -- Delete(string) bool |
75 | | -+ Delete(context.Context, string) bool |
76 | | - Clear() |
77 | | -} |
78 | | -``` |
79 | | - |
80 | | -## Upgrade from v3 to v4 |
81 | | -```diff |
82 | | -// dataloader.Interface as now allows interace{} as key rather than string |
83 | | -- loader.Load(context.Context, key string) Thunk |
84 | | -+ loader.Load(ctx context.Context, key interface{}) Thunk |
85 | | -- loader.LoadMany(context.Context, key []string) ThunkMany |
86 | | -+ loader.LoadMany(ctx context.Context, keys []interface{}) ThunkMany |
87 | | -- loader.Prime(context.Context, key string, value interface{}) Interface |
88 | | -+ loader.Prime(ctx context.Context, key interface{}, value interface{}) Interface |
89 | | -- loader.Clear(context.Context, key string) Interface |
90 | | -+ loader.Clear(ctx context.Context, key interface{}) Interface |
91 | | -``` |
92 | | - |
93 | | -```diff |
94 | | -// cache interface now allows interface{} as key instead of string |
95 | | -type Cache interface { |
96 | | -- Get(context.Context, string) (Thunk, bool) |
97 | | -+ Get(context.Context, interface{}) (Thunk, bool) |
98 | | -- Set(context.Context, string, Thunk) |
99 | | -+ Set(context.Context, interface{}, Thunk) |
100 | | -- Delete(context.Context, string) bool |
101 | | -+ Delete(context.Context, interface{}) bool |
102 | | - Clear() |
103 | | -} |
104 | | -``` |
105 | | - |
106 | | -## Upgrade from v4 to v5 |
107 | | -```diff |
108 | | -// dataloader.Interface as now allows interace{} as key rather than string |
109 | | -- loader.Load(context.Context, key interface{}) Thunk |
110 | | -+ loader.Load(ctx context.Context, key Key) Thunk |
111 | | -- loader.LoadMany(context.Context, key []interface{}) ThunkMany |
112 | | -+ loader.LoadMany(ctx context.Context, keys Keys) ThunkMany |
113 | | -- loader.Prime(context.Context, key interface{}, value interface{}) Interface |
114 | | -+ loader.Prime(ctx context.Context, key Key, value interface{}) Interface |
115 | | -- loader.Clear(context.Context, key interface{}) Interface |
116 | | -+ loader.Clear(ctx context.Context, key Key) Interface |
117 | | -``` |
118 | | - |
119 | | -```diff |
120 | | -// cache interface now allows interface{} as key instead of string |
121 | | -type Cache interface { |
122 | | -- Get(context.Context, interface{}) (Thunk, bool) |
123 | | -+ Get(context.Context, Key) (Thunk, bool) |
124 | | -- Set(context.Context, interface{}, Thunk) |
125 | | -+ Set(context.Context, Key, Thunk) |
126 | | -- Delete(context.Context, interface{}) bool |
127 | | -+ Delete(context.Context, Key) bool |
128 | | - Clear() |
129 | | -} |
130 | | -``` |
131 | | - |
132 | 40 | ### Don't need/want to use context? |
133 | 41 | You're welcome to install the v1 version of this library. |
134 | 42 |
|
|
0 commit comments