-
Notifications
You must be signed in to change notification settings - Fork 77
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
v2: use generics to enforce type invariants #43
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I ported Nomad's acl package to it, and it works just like you'd expect.
(Let's get at least one more stakeholder review before merging though since it's such a foundational package.)
59e77f0
to
3f7e9ee
Compare
Also update dependency
go.mod
Outdated
|
||
require ( | ||
github.com/hashicorp/go-uuid v1.0.0 | ||
github.com/hashicorp/golang-lru v0.5.0 | ||
github.com/hashicorp/golang-lru v0.5.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we update this dependency to the v2 version of golang-lru? (this one introduces generics for the cache as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, done!
Is this still being worked on? Anything I can do to help? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done a lot with Go generics yet, so not sure you want to trust my review, but this all seems sensible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 👏 !
A thought out of the scope of this PR but now that we are adding a v2 could we also make the key generic?
I took a stab into that a while back and the challenge is to find an elegant way of extracting the dependencies to the bytes
package. We use the following:
bytes.HasPrefix
bytes.Compare
bytes.Equal
Not sure if it's useful though 🤔
LGTM. I did notice that this comment has not been addressed, though. It's a trivial change, so I suggest including it. |
@dhiaayachi indeed I went down that rabbit hole for a bit myself - the increase in complexity is hard to justify without a clear benefit; but if that becomes apparent one day there can always be a v3 🙂 |
Thanks for the quick turn-around, everyone! 🎉 |
* Migrate acls to generics See hashicorp/go-immutable-radix#43 * deps: fixup go.mod formatting Co-authored-by: Seth Hoenig <shoenig@duck.com>
@shoenig After the use-generics branch is merged I'm not able to build my code which is using https://github.com/hashicorp/go-metrics which refers this code. I think generics are used in this repo incorrectly. Here is the error I'm getting:
|
If you are using the v2 module, you need to pass a type like r := iradix.New[string]()
r := iradix.New[any]()
// etc... The |
This PR introduces a v2 of
go-immutable-radix
, centered on utilizing generics.The major version bump is necessary because although the package is now generic, the exported type signatures have changed to be generic; rather than assuming
interface{}
in places.github.com/hashicorp/go-immutable-radix/v2
Closes #42
Closes #36
note: if this gets merged, be sure to tag with
v2.0.0
Adding some benchmarks (via this harness). I suspect in practice the performance difference is negligible - the differences here could just be luck with GC going one way or the other.