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

[Feature Request]: DefaultTypeResolver caching #437

Open
adambajguz opened this issue Sep 23, 2023 · 1 comment · May be fixed by #447
Open

[Feature Request]: DefaultTypeResolver caching #437

adambajguz opened this issue Sep 23, 2023 · 1 comment · May be fixed by #447
Labels
enhancement New feature or request

Comments

@adambajguz
Copy link

adambajguz commented Sep 23, 2023

Is your request related to a problem you have?

I think adding a cache in DefaultTypeResolver can improve performance and memoery allocations.

Describe the solution you'd like

private readonly ConcurrentDictionary<string, Type> _consumeTypeCache = new(StringComparer.Ordinal);
private readonly ConcurrentDictionary<Type, string> _produceTypeCache = new();

(...)
return typeName is null ?
   null :
   _consumeTypeCache.GetOrAdd(typeName, Type.GetType);

(...)

string messageTypeName = _produceTypeCache.GetOrAdd(
    messageType,
    static messageType => $"{messageType.FullName}, {messageType.Assembly.GetName().Name}");

context.Headers.SetString(MessageType, messageTypeName);

Are you able to help bring it to life and contribute with a Pull Request?

Yes

Additional context

No response

@adambajguz adambajguz added the enhancement New feature or request label Sep 23, 2023
@adambajguz
Copy link
Author

Also why DefaultTypeResolver is basically a transient dependency?

adambajguz added a commit to adambajguz/kafkaflow that referenced this issue Oct 8, 2023
@adambajguz adambajguz linked a pull request Oct 8, 2023 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

1 participant