lavinmq icon indicating copy to clipboard operation
lavinmq copied to clipboard

Refactor Reporter to not know about implementations

Open spuun opened this issue 1 year ago • 5 comments

WHAT is this pull request doing?

The Reporter class is an odd bird and only used for debugging purposes. It knows too much about classes (even accessing instance variables) which prevents refactoring.

This PR refactors Reporter to not know anything about any implementation; instead "reportable" entities must include the Reportable module and specify their reportable objects with the reportables macro.

The macro may look scary at a first glance, but it will generate a __report method that will report all specified "reportables" to the Reporter instance. This makes the Reporter only responsible for the output, while each entity is responsible for what to report.

HOW can this pull request be tested?

Run lavinmq and send USR1 to observe output.

spuun avatar May 14 '24 06:05 spuun

What's the benefit? "Prevents refactoring"? You have to change your reportables just the same way as you have to change the Reporter today. With this PR a lot of debugging code is scattered around in individual classes.

carlhoerberg avatar May 16 '24 09:05 carlhoerberg

IMO changing the internals of a class shouldn't affect other classes. I encountered this when I was abstracting client/channel/consumer.

spuun avatar Jun 14 '24 11:06 spuun

This makes sense. Could be used for general instrumentation and not only debugging?

dentarg avatar Jul 08 '24 09:07 dentarg

The current approach doesn't work very well if you start to abstract things, like making Client an abstract class to introduce amqp clients and mqtt client, since these different client classes may have different internals.

spuun avatar Aug 07 '24 07:08 spuun

Sure but question is if this is useful at all?

On Wed, 7 Aug 2024, 09:48 Jon Börjesson, @.***> wrote:

The current approach doesn't work very well if you start to abstract things, like making Client an abstract class to introduce amqp clients and mqtt client, since these different client classes may have different internals.

— Reply to this email directly, view it on GitHub https://github.com/cloudamqp/lavinmq/pull/676#issuecomment-2272838906, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABL6TSH6MNMA4D44HJE4QDZQHGNLAVCNFSM6AAAAABHVRNE6WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZSHAZTQOJQGY . You are receiving this because your review was requested.Message ID: @.***>

carlhoerberg avatar Aug 08 '24 06:08 carlhoerberg