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

Allow more flexible consumer signature #2

Open
elliotchance opened this issue Jul 24, 2019 · 1 comment
Open

Allow more flexible consumer signature #2

elliotchance opened this issue Jul 24, 2019 · 1 comment

Comments

@elliotchance
Copy link

The consumer uses func(ls []interface{}) error which requires that all elements be individually cast:

consumer := func(ls []interface{}) error {
	var items []int
	for _, item := range items {
		items = append(items, item.(int))
	}

	// ...
	return nil
}

Using reflect you could have a dynamic signature (which would be backwards compatible with []interface{}):

consumer := func(ls []int) error {
	fmt.Printf("get %+v \n", ls)
	wg.Add(-len(ls))
	return nil
}
@jiacai2050
Copy link
Owner

Hi elliotchance, Do you have any PR to improve this?

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

No branches or pull requests

2 participants