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

add customizable partitioner #1118

Merged
merged 2 commits into from
Jun 15, 2018
Merged

add customizable partitioner #1118

merged 2 commits into from
Jun 15, 2018

Conversation

mier85
Copy link
Contributor

@mier85 mier85 commented Jun 15, 2018

So the partitioner has a lot of different partitioner constructors now, and they contain functionality which cannot all be created without creating new custom constructor functions for each.

This PR introduces a customizable partitioner which works with functions as options. New added options will not break the current behavior nor will it break the function signature. That will let us introduce new options while we are still backwards compatible.

For reference:
https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

@eapache
Copy link
Contributor

eapache commented Jun 15, 2018

Ya, I was noticing this issue as well. In a from-scratch world (or if I ever do a major version bump) I think I might simply provide a single NewHashPartitioner which is properly compatible with the upstream/reference implementation, and if you want anything else you can implement your own partitioner. They're not exactly large or complicated.

In the meantime, I suppose this is probably the best we can do.

partitioner.go Outdated
}
}

// WithCustomRandomPartitioner lets you specify what HashPartitioner should be used in case a Distribution Key is empty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/HashPartitioner/Partitioner

partitioner.go Outdated
}

// WithCustomRandomPartitioner lets you specify what HashPartitioner should be used in case a Distribution Key is empty
func WithCustomRandomPartitioner(randomHP *hashPartitioner) HashPartitionerOption {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might call this WithCustomFallbackPartitioner

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes much more sense, I'll update it.

@eapache eapache merged commit 9f7c4d9 into IBM:master Jun 15, 2018
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