-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Async Keys implementation #6457
Conversation
sdk/keyvault/Azure.Security.KeyVault.Keys/src/RsaKeyCreateOptions.cs
Outdated
Show resolved
Hide resolved
return true; | ||
} | ||
|
||
private static bool AreEqual(byte[] a, byte[] b) |
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.
Instead of writing this routine by hand, use Span.SequenceEqual. It's much more efficient.
sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyImportOptions.cs
Outdated
Show resolved
Hide resolved
{ | ||
internal void Deserialize(Stream content) | ||
{ | ||
using (JsonDocument json = JsonDocument.Parse(content, default)) |
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.
Out of curiosity, any particular reason to not use the JsonSerializer
?
sdk/keyvault/Azure.Security.KeyVault.Keys/src/RsaKeyCreateOptions.cs
Outdated
Show resolved
Hide resolved
sdk/keyvault/Azure.Security.KeyVault.Keys/src/RsaKeyCreateOptions.cs
Outdated
Show resolved
Hide resolved
A Key cannot have more than one type. This shouldn't be a flags enumeration Refers to: sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyType.cs:13 in 6788f44. [](commit_id = 6788f446d1aa1b60bf2e4621f9129167b00a68c2, deletion_comment = False) |
Given that all the enums in this assembly need to support values which are not explicitly in the enumeration perhaps they should be structs instead of simple enums. This way we could also store the actual string in the case we can't parse them. Refers to: sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyType.cs:20 in 6788f44. [](commit_id = 6788f446d1aa1b60bf2e4621f9129167b00a68c2, deletion_comment = False) |
{ | ||
var writer = new ArrayBufferWriter<byte>(); | ||
|
||
var json = new Utf8JsonWriter(writer); |
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.
If serializing things is done frequently, you might consider pooling writers (if you are using a version of the package where they're a class) via ConcurrentBag (or some other pooling technique). It reduces the GC impact of creating the write buffers.
Of course, then you need a strategy for knowing when to not return an object to the pool... but maybe "always pool" is fine.
PR Updated with feedback |
Is there something else I should address? or are we good to go to merge this as the first iteration of the Keys async implementation |
Async implementation of:
Similar to what we did for Secrets API