-
Notifications
You must be signed in to change notification settings - Fork 606
Add ReadOnlyMemory overload to BasicPublish #788
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 ReadOnlyMemory overload to BasicPublish #788
Conversation
I definitely like the idea but one thing in the implementation colored me surprised. |
The byte[] overload for publish might be unnecessary now since byte[] can be implicitly cast to ReadOnlySpan. I'll review this later tonight :) |
@@ -1108,10 +1108,14 @@ public void MaybeEmitModelMethod(MethodInfo method) | |||
|
|||
public string SanitisedFullName(Type t) | |||
{ | |||
if (t.FullName.StartsWith("System.Collections.Generic.IDictionary`2[[System.String")) | |||
if (t.Equals(typeof(IDictionary<string, object>))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous approach had a potential bug in that it would treat any IDictionary<string, T>
as IDictionary<string, object>
, so this is definitely better.
@stebet I was just about to suggest the same thing. Seems like it makes sense to drop the |
Yeah. I'll review later and do some experiments. |
It makes sense. I can update this PR. |
@Anarh2404 @stebet @bording there is a lot of code out there on the Internet that demonstrates using a byte array. Having an overload is a must but we can make it secondary to the one that uses We can update our tutorials use |
The reason we're suggesting this is that nothing changes to the consumer. They continue to use byte arrays.
There's no reason to keep having a |
OK, thanks for clarifying. |
ReadOnlySpan is actually the lowest abstraction. If this can be modified to work with rhat, it should work with pretty much everything (Span, arraysegments, byte arrays, memory). |
ReadOnlySpan may be a problem when a fully async version is being developed, because ReadOnlySpan cannot be an argument of an async methods. |
Always great to both extend the API for more modern ways of doing things and remove the original API bits without losing backwards compatibility 😮 Thank you so much @Anarh2404 @bording @stebet! 👏 |
Proposed Changes
Add ReadOnlyMemory overload to BasicPublish.
That allows to send part of the array without creating a new one.
Types of Changes
Checklist
CONTRIBUTING.md
document