Skip to content

Conversation

@rymndhng
Copy link
Contributor

@rymndhng rymndhng commented Feb 12, 2018

  1. Remove boxing & allocation where possible
  2. Make API consistent (remove keyword args, because it cannot be mixed with
    primitive typehints)

Fixes #2

1. Remove boxing & allocation where possible
2. Make API consistent (remove keyword args, because it cannot be mixed with
primitive typehints)
(.incrementCounter client metric sample-rate tags)
(.incrementCounter client metric tags))))
([metric]
(.incrementCounter client metric -empty-array))
Copy link
Contributor Author

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)))))
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

(defonce ^:private ^StatsDClient client (NoOpStatsDClient.))

(defn str-array [tags]
(def ^:private ^"[Ljava.lang.String;" -empty-array (into-array String []))
Copy link
Contributor

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 😕

Copy link
Contributor Author

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

Copy link
Contributor

@gzmask gzmask left a comment

Choose a reason for hiding this comment

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

@rymndhng
Copy link
Contributor Author

This PR hasn't removed test.check. Can we re-base #3 after this issue is merged?

Copy link
Contributor

@gzmask gzmask left a comment

Choose a reason for hiding this comment

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

LGTM!

@rymndhng rymndhng merged commit 8eda539 into master Feb 16, 2018
@rymndhng rymndhng deleted the cleanup-api branch February 16, 2018 22:51
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