Closed martinssipenko closed 4 years ago
I'm down for that if others are open to it - the only thing is it's a huge method signature change and would not be backwards compat. So we'd have to solve this in one of the following ways (open to others, these are just the ideas I can see):
I personally like the names constructor option. Let me try it out and I'll send some code your way when I have something to show.
Just noticed that $this->openConnection();
is being called in all methods. This would gave to change in case Redis is injected as the connection would have been established already.
I see two options here:
__construct
.openConnection
method that would check against private property, if it's set openConnection
would exit early.WDYT?
Here is a draft PR: https://github.com/endclothing/prometheus_client_php/pull/8
The existing connection would still have to be injected, but nice find!
Closed by #8
Rigth now
\Redis
client is constructed within__construct
method ofPrometheus\Storage\Redis
class. What thoughts do you have on adding ability to inject\Redis
into storage class? This would allow to reuse already existing connection from framework.I'm happy to contribute the code change if/when it's decided to do it and what would be the best approach to do it.