I’m trying to develop my new topologies using a proper design pattern, to achieve :
- Reusability of class
- Unit testing / at least functional
o Be able to mock database interaction through interfaces
I worked a lot with PHP & Symfony which is a great framework to achieve those goals using dependency injection pattern
I want to apply it to Storm topology development, but here is my problem :
How can I pass dependency in constructor (e.g Cassandra provider, or id resolver, or even object hydrator), the bolt are instantiated when calling “prepare” method
If I’m using a DI framework (like google Guice), how can I Mixed it with storm topology builder ?
One idea :
I think I can pass factories to my constructor and instantiate object in prepare method of my bolt
But I’m not sure if it a good way to do it..
Did anybody ever experience it ?
Does anyone have some best practices to develop topologies ? (regarding code engineering and organization)
Thanks in advance,