-
Notifications
You must be signed in to change notification settings - Fork 7
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.
Really good work, just a few small things.
if version == "" { | ||
_, version = s.pathVersionFromKey(string(resp.Responses[2].GetResponseRange().Kvs[0].Key)) | ||
version = versions[len(versions)-1] |
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.
We could also have stored the result of the len
we did on the kvs
above. Micro-optimisation, mind you ;-)
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.
Actually, IIRC len
is constant time, unlike C's strlen
which is O(n) and justifies caching the length to reuse it.
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.
Not just constant time - it can even be registerised if the compiler decides it's worth it :)
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 knew it was constant time, but pushing it to the register, I didn't.
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 job man! 👍
Few comments to address.
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 FWIW; nice simplifications. I haven't looked at the test code in detail, but I've got a few minor comments and suggestions.
if version == "" { | ||
_, version = s.pathVersionFromKey(string(resp.Responses[2].GetResponseRange().Kvs[0].Key)) | ||
version = versions[len(versions)-1] |
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.
Not just constant time - it can even be registerised if the compiler decides it's worth it :)
api/service.go
Outdated
PathsOnly bool // return only the paths of the rulesets | ||
AllVersions bool // return all versions of each rulesets | ||
Limit int // If the Limit is lower or equal to 0 or greater than 100, it will be set to 50 by default. | ||
Cursor string // pagination cursor |
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.
Perhaps mention that if this is empty, the list starts from the beginning?
Package
regula
: Removed redundant ruleset validation code, theapi
package already does thatPackage
errors
: Removed unnecessary errors, these errors should not be "catchable" and represent something bad that shouldn't happen in normal conditionsPackage
api
:•
List
now returns a simple list of paths, with pagination. No prefix.• Put now returns the version string, not the ruleset
• Renamed
ContinueToken
toCursor
Package
api/etcd
:• The change of behaviour of the
List
andPut
APIs simplified a lot the etcd implementation. Lots of code removed• Tests have been split into multiple files
Package
http
:• Tests have been rewritten into table tests and split
• Applied changes from the API