liuggio / statsd-php-client

Statsd (Object Oriented) client library for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[rfc] Move sender parameter into an Object or into the Sender

liuggio opened this issue · comments

The StatsdClient constructor has hostname and port as parameters,
maybe should be better put these parameter into the sender.

Example now:

$sender = new SocketSender();
$client = new StatsdClient($sender, $hostname, $port);

Option A
With Parameters as object :

$sender = new SocketSender();
$parameter = new StatsdParameter($hostname, $port, ...);
$client = new StatsdClient($sender, $parameters);

Option B
With Parameters into the Sender:

$sender = new SocketSender($hostname, $port);
$client = new StatsdClient($sender);

Any comment are appreciated.

Host and port params are specific for SocketSender so I would move them to SocketSender. As far as StatsdClient is concerned, it should just call open/write/close methods on any Sender object. Also you could extend the lib. so it is possible to stack several senders. Use case for this is sending data to FirePHP/ChromePHP for debugging purposes along sending it to statsd, or logging it to a file.

Great, I totally agree.
Do you want contribute?

Yeah, I'm interested as I plan to use this lib. for one of my projects.

any PR will be really appreciated 👍

Nope, not yet, I haven't made it yet to work on this, I'll start somewhere end of the next week