Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose fetch, wait and maxbatch, so that they are no longer internals #12

Closed
wants to merge 1 commit into from

Conversation

udayreddy
Copy link

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.

@vektah
Copy link
Owner

vektah commented Aug 31, 2018

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.
image

By making these public this interface becomes very muddy
image

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) {
			...
		},
	}

@udayreddy
Copy link
Author

@vektah After putting some thought , what you say makes sense. let me close the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants