vladmihalcea / flexy-pool

FlexyPool adds metrics and failover strategies to a given Connection Pool, allowing it to resize on demand.
Apache License 2.0
1.09k stars 120 forks source link

Ability to override MetricsFactory used #46

Closed johnament closed 6 years ago

johnament commented 6 years ago

While looking at https://github.com/vladmihalcea/flexy-pool/blob/master/flexy-pool-core/src/main/java/com/vladmihalcea/flexypool/metric/MetricsFactoryResolver.java I saw that:

Basically, everything against SOLID

I was hoping that at runtime, I could replace the resolver to use my own resolver, or somehow replace the behavior. To do that, I would need to change something within Flexy Pool. That's not possible. Ideally, what I'd like to do is extend the DWM metrics implementation, since my metrics are based on it, but use my CDI provided MetricsRegistry as the backing object instead. There's no way to do that, without duplicating a lot of logic.

vladmihalcea commented 6 years ago

You should not need to extend this class. This one resolves MetricsFactoryService. That's why it's final.

You can provide a custom MetricsFactory and pass it via setMetricsFactory. That's how it was designed to customize the Metrics you want to use.