obmarg / kazan

Kubernetes API client for Elixir
https://hex.pm/packages/kazan
MIT License
138 stars 35 forks source link

Allow replacing of Kazan.Client.Imp via configuration #75

Open chazsconi opened 4 years ago

chazsconi commented 4 years ago

As mentioned in https://github.com/obmarg/kazan/pull/72 we have a wrapper around Kazan.run/2 for instrumentation.

It would be useful if the module that Kazan.run/1 and Kazan.run/2 delegates to could be changed by configuration. This way we could easy provide our own implementation which wraps calls to Kazan.Client.Imp.run/2 with instrumentation.

This would also be useful to allow Kazan.Client.Imp to be replaced by a mock module for testing an app that uses Kazan.

To do this I would also suggest moving Kazan.Client.Imp.run!/2 to the Kazan module (as it's just a wrapper around run/2) and leaving run/2 as the only function that is required to be implemented in Kazan.Client.Imp or a mock implementation. A behaviour could also be added.

@obmarg I can provide a PR for this if you agree with the approach.

obmarg commented 4 years ago

This is an interesting idea, not one I'd considered. Not sure where I stand: is there a reason to do this in Kazan vs. implementing this in your app?