MetaBrainz Foundation
Remove code duplication from ListenBrainz's different modules
Don't Repeat Yourself is a principle in software development that all MetaBrainz projects try to follow as much as possible. Three different modules of ListenBrainz: bigquery-writer
, influx-writer
and webserver
connect to RabbitMQ using similar code.
This task involves consolidating this similar code into a function which should then get called by each module when it wants to connect to RabbitMQ.
influx-writer
connects to RabbitMQ in this file: https://github.com/metabrainz/listenbrainz-server/blob/master/listenbrainz/influx-writer/influx-writer.py#L55bigquery-writer
connects to RabbitMQ in this file: https://github.com/metabrainz/listenbrainz-server/blob/master/listenbrainz/bigquery-writer/bigquery-writer.py#L41webserver
connects to RabbitMQ in this file: https://github.com/metabrainz/listenbrainz-server/blob/master/listenbrainz/webserver/rabbitmq_connection.py#L8
To complete this task, you should add a function that connects to RabbitMQ in listenbrainz/utils.py
and call it in each of the above places, so that we only have
one piece of code to connect to RabbitMQ.
Task tags
Students who completed this task
Eshan Singh