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

use send_stat instead of overriding ruby send method #13

Closed
wants to merge 7 commits into from

Conversation

sensadrome
Copy link
Contributor

in some implementations of the code we might want to call something like:

type = :increment

$statsd.send(type, my_stat)

but this would not work because send has been aliased to one of send_to_buffer or send_to_socket

@yannmh yannmh self-assigned this Apr 2, 2015
@yannmh
Copy link
Member

yannmh commented Apr 2, 2015

Thanks a lot @sensadrome for your contribution.

I really like the code cleaning 😄 but I am not sure to understand what's exactly the issue you're experiencing with statsd.send, and how your changes solve it. Could you give us more details please ?

On a side note, it seems that these changes break the test suite.

@yannmh
Copy link
Member

yannmh commented Apr 27, 2015

@sensadrome any update about this PR ?

@sensadrome
Copy link
Contributor Author

@yannmh sorry - been busy! - so "send" is an inbuilt ruby method on Object (http://ruby-doc.org/core-2.2.2/Object.html#method-i-send) - technically speaking we could use "send" instead which I think another dev suggested. In your code you specify "alias :send :send_to_socket" which effectively overwrites the Object.send method and thus leads to unexpected behaviour....

essentially your send method switches between send_to_socket and send_to_buffer which is nice - but instead of using :send as the alias I have used :send_stat

Hope that makes sense!

Re the tests, I can see that this is part of the rewrite for the initialiser - so I would have to rewrite the tests. Happy to do so if you think you'd like to include my changes...

@sensadrome
Copy link
Contributor Author

@yannmh OK - I have updated the code and adjusted the spec helpers to initialise the object with a hash instead of ordered args. Tests all pass now ... sorry, should have done that before!

@sensadrome
Copy link
Contributor Author

should ruby 1.8.7 be removed as a target build, since i18n requires 1.9.3 ?

def initialize(host = DEFAULT_HOST, port = DEFAULT_PORT, opts = {}, max_buffer_size=50)
self.host, self.port = host, port
@prefix = nil
def initialize(opts = {})
Copy link
Member

Choose a reason for hiding this comment

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

This is unfortunately breaking backward incompatibility as we are changing the method signature 😢 , i.e.

s = Statsd.new('localhost', 1234)
ArgumentError: wrong number of arguments (2 for 0..1)

@yannmh
Copy link
Member

yannmh commented May 19, 2015

Thanks a lot for your work and the further information @sensadrome !

We'd like to merge your contribution and release a new gem. Unfortunately some of them are breaking backward incompatibility (i.e. comment made above).
If you don't mind, I'll restablish initialize method original signature, and also rebase your work on top of current master state (to solve merge conflicts). Please let me know what you think.

@yannmh
Copy link
Member

yannmh commented May 19, 2015

To avoid backward incompatibilities issues, I opened a new PR #17 with your first commit cherry-picked.
I am also closing this one: I think it's wiser to bring other commits in a different PR, so they can be reviewed independently. Please feel free to re-open a new one 😃 .

Thanks again.

@yannmh yannmh closed this May 19, 2015
@sensadrome
Copy link
Contributor Author

yes fair enough - I hadn't thought about backward compatibility. Happy to add the code to cover it if you like - right now we're just using the gem directly from our own repo, but ultimately would be better to use yours :)

Let me know...

@yannmh
Copy link
Member

yannmh commented May 20, 2015

@sensadrome, that would be great ! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants