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 DI to easily allow swapping out repositories/services? #64

Closed
jlkalberer opened this issue Jan 6, 2017 · 4 comments
Closed

Use DI to easily allow swapping out repositories/services? #64

jlkalberer opened this issue Jan 6, 2017 · 4 comments

Comments

@jlkalberer
Copy link

@AntonPuko @wdimmit @durielz

I'm thinking of using a IoC framework in order to easily swap out the different repositories used here. This change will cascade down into the protocol layer.

I think the change will make swapping out certain implementations much easier but I want some feedback before I start as this is a super opinionated change.

An example of why we should do this is:
Right now we have concrete implementations of saving device attributes and server keys to the local file storage. Yes you can change the path via settings but what if you want to fetch these via HTTP or using some storage API (Azure) or whatever the AWS storage is.

By moving over to a framework like this we would be able to swap out implementations by adding a single line and the configuration would cascade down.

Here is one I'm looking at because it's fairly simple and light-weight.

@wdimmit
Copy link

wdimmit commented Jan 6, 2017

@jlkalberer I think in the long run this would be a good change. Some load balancing strategies in particular would greatly benefit from not using local storage for attributes and keys.

Cheers!

@jlkalberer
Copy link
Author

Thanks.. I just wasn't sure if it would be OK with the change because it will really add some opinionated code. I think the benefits will really help out with maintaining this codebase though.

@durielz
Copy link

durielz commented Jan 7, 2017

I think having some opinionated code is not so bad, it can encourage developers to follow your design. I have never worked with DI and IOC in JavaScript but I have experiences with Symfony that makes a large use of DIC so i guess it could bring only benefits.

@jlkalberer
Copy link
Author

Ok, this wasn't as bad as I thought. Instead of using the @Dependencies syntax, I added some files that set up the bindings. Everything seems to be working as the change wasn't too large.

@AntonPuko - I think your tests should be verifying that all the APIs work but I'm guessing there are some new APIs that don't have tests yet.

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

No branches or pull requests

3 participants