Skip to content

Allow more flexible consumer signature #2

@elliotchance

Description

@elliotchance

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions