Closed udayreddy closed 6 years ago
Thanks for the PR, but I don't think this is the right move.
The idea behind keeping them private is to hide the implementation from the rest of the app as much as possible.
The public interface is currently designed to be for the calling code, not the implementation.
By making these public this interface becomes very muddy
Should I call Fetch or Load? What happens if I change MaxBatch or Wait?
Maybe a NewXLoader
method that takes a config object addresses both of these concerns? It keeps the runtime interface separate from the setup, but still allows you to work out of the package if you want, without breaking existing code.
eg:
ldrs.UsersById = NewUserLoader(loader.UserLoaderConfig{
Wait: 2 * time.Millisecond,
MaxBatch: 200,
Fetch: func(keys []int) ([]*api.User, []error) {
...
},
}
@vektah After putting some thought , what you say makes sense. let me close the PR
this will be useful for package management , and generated files can be packaged separately and remove dependency for the middleware to be in the same package.