Currently I am working on a data pipeline project utilizing Apache Kafka and Erlang as a stream processor language (I have actually no previous experience with erlang except learning the language and the concepts since the beginning of the year). To write Kafka consumers we rely on the rock solid brod module.
I understand, that I have to write a supervisor callback module which is responsible for starting my brod_client and my group_consumer module.
my_app
+-- my_sup
+-- brod_client
+-- my_group_consumer
this group_consumer module I wrote is a callback module for the brod_group_subsriber_v2 behaviour which in itself is a callback module for gen_server.
my_group_consumer > brod_group_subscriber > gen_server
When I run my application, my supervisor is starting the brod_client, but not my consumer erlang:whereis(my_group_consumer).
returns undefined
. Only after a message reaches in, the brod_group_consumer_v2 itself seems to intitalizes my_group_consumer and calls its message handler function. This "lazy" init makes sense for me, but differs from what I would expect as I configured the supervisor to explicitely take care of my_group_consumer (not its base behaviour).
So after all this I am not sure if I understand behaviours exactly and therefore if I am using the brod modules correctly, as I try to inherit from them as I would with Java class inheritance and polymorphism.
Its very hard to find examples where brod is used in a supervisor and not just on the shell for demo purposes.
EDIT: I am using brod as an example of a situation/use case here, where I expected the implementation of most specialised module to "inherit" from the mst generic one, which doesn't seem to be the case and therefore I am not able to use a module like brod correctly.
Would somebody please explain me the differences of the concepts? If you like to explain it according to my example it would be great, if you can explain it with another example or no example at all...also fine, thanks in advance.