Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Default Message Mapper #3407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add Default Message Mapper #3407

wants to merge 1 commit into from

Conversation

preardon
Copy link
Member

@preardon preardon commented Dec 2, 2024

First look into Default Message Mapper

#3355

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

Change in average Code Health of affected files: +0.07 (9.17 -> 9.24)

View detailed results in CodeScene

@@ -379,7 +379,9 @@ public static MessageMapperRegistry MessageMapperRegistry(IServiceProvider provi

var messageMapperRegistry = new MessageMapperRegistry(
new ServiceProviderMapperFactory(provider),
new ServiceProviderMapperFactoryAsync(provider)
new ServiceProviderMapperFactoryAsync(provider),
Copy link
Member

Choose a reason for hiding this comment

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

This may be your comment around async and sync, the fact that we have to register two. The only way around this would be to make all default message mappers implement both. That might be a problem in contexts where it is hard to provide either one of those, due to constraints on libraries used. But it is a little gnarly.

However, we can provide default mappers that implement both

public Dictionary<Type, Type> Mappers { get; } = new Dictionary<Type, Type>();
public Type DefaultMessageMapper { get; private set; } = typeof(JsonMessageMapper<>);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to default the default here, or do we just do that in the extensions DSLs?


var header = new MessageHeader(messageId: request.Id, topic: publication.Topic, messageType: messageType);

var body = new MessageBody(JsonSerializer.Serialize(request, JsonSerialisationOptions.Options));
Copy link
Member

Choose a reason for hiding this comment

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

In principle there is an async serializer. I am not sure if it actually has meaning. But we should investigate. The MS route here is to pass an enum flag to the common method and then just use sync or async code in the body, based on that flag as needed

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@iancooper iancooper left a comment

Choose a reason for hiding this comment

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

This looks really good. I can add a default Avro as well later

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