-
Notifications
You must be signed in to change notification settings - Fork 5
Clean up the API for consistency #4
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
Conversation
5c0816a
to
40db9b9
Compare
1. Remove boxing & allocation where possible 2. Make API consistent (remove keyword args, because it cannot be mixed with primitive typehints)
40db9b9
to
ac8a340
Compare
(.incrementCounter client metric sample-rate tags) | ||
(.incrementCounter client metric tags)))) | ||
([metric] | ||
(.incrementCounter client metric -empty-array)) |
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.
FWIW i split it up this way because I think this would be a faster path on the critical path because it does away w/ adding sample rate or tags (by calling .incrementCounter directly)
sample-rate ^Double sample-rate] | ||
(if sample-rate | ||
(.recordGaugeValue client metric value sample-rate tags) | ||
(.recordGaugeValue client metric value tags))))) |
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.
@gzmask I cleaned this API up a bit to remove the need to create an anonymous function
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.
Reason of the anonymous function is that I wanted to get rid of the propagate effect of type annotations - so that clojure code remains clojurish and Java types are localized to where the interop happens. Not sure if this is a good practice.
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'm uncertain what propogate effects you're thinking of.
From the outside you won't need to know about the typehints. The typehints are used to help the clojure compiler pick a function rather than use reflection.
|
||
(defn str-array [tags] | ||
(def ^:private ^"[Ljava.lang.String;" -empty-array (into-array String [])) |
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 was trying to look up the ^"[Ljava.lang.String;" thing and didn't know what to google for 😕
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.
It's a typehint for a string array
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.
Can you add back deps for test.check?
see:
https://github.com/unbounce/clojure-dogstatsd-client/pull/3/files#diff-3f8f408345fa9ba7415df1b86d9e6424R11
This PR hasn't removed test.check. Can we re-base #3 after this issue is merged? |
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!
primitive typehints)
Fixes #2