Skip to content

Conversation

@thompson-tomo
Copy link
Contributor

@thompson-tomo thompson-tomo commented Jun 2, 2025

This does some basic refactoring to prepare for #871 with the key focus being to pass record of operation properties rather than multiple variables.

As part of this change the following has been introduced:

  • Nats{{operation}}Props: which are used to package up the properties and past through the call stack

Potential Breaking changes:

  • ReceiveInternalAsync within NatsSubBase has introduced a new overload designed in a backward compatitable way

@thompson-tomo thompson-tomo changed the base branch from main to release/2.7 June 2, 2025 15:39
@thompson-tomo thompson-tomo changed the title Refsctor: pass around record of properties for operation WIP: Refactor: pass around record of properties for operation Jun 2, 2025
@thompson-tomo thompson-tomo force-pushed the Task/passRecords branch 2 times, most recently from 43fe93d to 5f7701a Compare June 3, 2025 03:19
@thompson-tomo thompson-tomo force-pushed the Task/passRecords branch 2 times, most recently from c6b9e3f to 73d2a24 Compare June 4, 2025 05:39
@@ -0,0 +1,19 @@
namespace NATS.Client.Core;

public record NatsPublishProps : NatsMessagingProps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have these props as structs? we don't want to contribute to GC especially with every publish for example. Also we can't change the public interfaces (haven't seen any yet, but just in case there are changes to them)

Copy link
Contributor Author

@thompson-tomo thompson-tomo Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately you can't do inheritance with structs and in a couple of locations it takes a base class. in fact the rabbitmq client uses classes for this example https://rabbitmq.github.io/rabbitmq-dotnet-client/api/RabbitMQ.Client.BasicProperties.html but given it is a DTO, a record felt more right to me and it allows properties to be updated after initialisation.

@mtmk
Copy link
Member

mtmk commented Jun 4, 2025

thanks for this @thompson-tomo had a quick scan through I appreciate your care about the public interface we have to make sure not the break existing dependencies to us. the main comment i'd have is about performance. would be good to run some of the benchmarks and my gut feeling is to have the props as structs rather than classes will probably help.

edit: i just realize it's still WIP but hope it helps anyway

@thompson-tomo
Copy link
Contributor Author

Agree @mtmk that we need to be careful not to impact existing dependencies hence the new internal methods etc. This is almost done with the main outstanding being review of accessibility modifiers, code comments & the UNKNOWN param scenario.

@thompson-tomo thompson-tomo changed the base branch from release/2.7 to main June 4, 2025 14:21
@thompson-tomo
Copy link
Contributor Author

thompson-tomo commented Jun 4, 2025

@mtmk So it might be difficult to get reliable benchmarks given the current setup is producing such significant variance in results but based on last results & comparing it to a test from when I cleaned up the csproj file. The throughput has increased but at the same time the memory usage also went up. At the same time the allocated memory also sharply rose but not sure if issue due to short test run.

@thompson-tomo thompson-tomo changed the base branch from main to release/2.7 June 5, 2025 02:53
@thompson-tomo thompson-tomo changed the title WIP: Refactor: pass around record of properties for operation Refactor: pass around record of properties for operation Jun 5, 2025
@thompson-tomo thompson-tomo force-pushed the Task/passRecords branch 11 times, most recently from e9d7c75 to ff6e44b Compare June 5, 2025 14:23
@thompson-tomo thompson-tomo requested a review from mtmk June 5, 2025 14:52
@thompson-tomo thompson-tomo force-pushed the Task/passRecords branch 6 times, most recently from 6b0a882 to 5cc77bd Compare June 10, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants