event-driven-io / Blumchen

Blumchen - Push-based Outbox for PostgreSQL
MIT License
90 stars 10 forks source link

Try to avoid reflection usage in IConsume #17

Open oskardudycz opened 3 months ago

oskardudycz commented 3 months ago

Per discussion: https://github.com/oskardudycz/PostgresOutboxPatternWithCDC.NET/pull/7#discussion_r1629335230

About: https://github.com/oskardudycz/PostgresOutboxPatternWithCDC.NET/blob/3d42e3552956cecfd1773e97a9afd0170ada0937/src/PostgresOutbox/Subscriptions/Subscription.cs#L138

@oskardudycz:

CONCERN: Is this used to call the generic method of the IConsume? If yes, then I'd recommend extending IConsume to have a method accepting an object message, then default implementation in IConsume that would call the typed method. This would reduce the need for this reflection access here, we could just call it.

@lsfera

We might support different scenario. A truly confident user could simply decide to deal with raw data, hence a basic IConsume would be enough. Or he would rather prefer to work typed data and generics support, hence some sort of (memoized)reflections stuff should unavoidable. Some benchmark here might help in solving the dilemma of reflection adoption.

lsfera commented 2 months ago

I'm working on a prototype the following these assumptions:

The consumer code: image

Here are the contracts: image

The goal is to read jsonb as a string image

or as an object

image

This way we should be able to address all use cases but binary format.

oskardudycz commented 2 months ago

Interesting. If you have some draft, I'm happy to take a look to learn more about that.

Also, FYI, from 13th July till the end of the month, I'm on vacation, and I plan to be offline to recharge a bit, but I plan to also do more work on Blumchen in August.

lsfera commented 2 months ago

This summer I'm having shorter breaks - a week or less - every month so that kids have feelings of longer vacations... We'll see how effective this strategy works, but I can definitely say that it's exhausting :-;

I'm playing with this branch - https://github.com/lsfera/Postgresql.Outbox/tree/serialization - to cover more jsonb options skipping deserialization when not needed Here's https://github.com/lsfera/Postgresql.Outbox/blob/serialization/src/Subscriber/Program.cs#L35-L39 how you can make use of new functionalities