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

Public default settings #191

Merged
merged 7 commits into from
Apr 17, 2020

Conversation

sorenhansen
Copy link
Contributor

Continuing along the lines of PR #189, this PR makes
DefaultMessagePropertyToIdentitySasUri and DefaultSasTokenValidationTime public.

Again, the reason being that the default values can be used by consumers in order (for example) to implement cleanup.

@SeanFeldman
Copy link
Owner

@SeanFeldman
Copy link
Owner

README.source.md Outdated
```c#
new AzureStorageAttachmentConfiguration(storageConnectionString).WithSasUri(messagePropertyToIdentifySasUri: "mySasUriProperty");
```
Default SAS token validation time is 7 days. The value is available via `AzureStorageAttachmentConfigurationExtensions.DefaultSasTokenValidationTime` constant.
Copy link
Owner

Choose a reason for hiding this comment

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

👍 on documenting the default value.

```
Default SAS token validation time is 7 days. The value is available via `AzureStorageAttachmentConfigurationExtensions.DefaultSasTokenValidationTime` constant.

snippet: Configure_blob_sas_uri_override
Copy link
Owner

Choose a reason for hiding this comment

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

Thank you for replacing hardcoded snippet with a verifiable code snippet 👏

@@ -11,6 +11,8 @@ namespace Microsoft.Azure.ServiceBus
}
public static class AzureStorageAttachmentConfigurationExtensions
{
public const string DefaultMessagePropertyToIdentitySasUri = "$attachment.sas.uri";
public static readonly System.TimeSpan DefaultSasTokenValidationTime;
Copy link
Owner

Choose a reason for hiding this comment

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

What's the value of exposing this? If the default is documented and known, how you would use this publicly exposed member field in your code? I'd like to understand how it would be used in the customer/user code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The argument is the same as on #185

Focusing on ContainerName and MessagePropertyToIdentifyAttachmentBlob let's assume you're using the defaults. Both properties, ContainerName and MessagePropertyToIdentifyAttachmentBlob have their defaults provided by the plugin which you'd need to use. Those are well documented and will not change to keep wire compatibility. You can use those strings in your code. My understanding is you don't like to use the strings and rather have something strongly types exposed by the AzureStorageAttachmentConfiguration class. That can be done, don't see an issue with it.

I would like to have access to a strongly typed values, so I don't have to worry about the values, even though I know they won't change. It reduces complexity (albeit not much) in my code.

I hope it makes sense.

Copy link
Owner

Choose a reason for hiding this comment

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

I would like to have access to a strongly typed values, so I don't have to worry about the values, even though I know they won't change.

Absolutely. That's why it makes sense to have access to the defaults of the SAS URI property, the container name, and the blob identifier property. I can trace how you'd be using that in your code if you need to access the SAS URI property/container/message property for blob name. What I don't see is how the default SAS token validation time is used?

It reduces complexity (albeit not much) in my code.

@sorenhansen, could you show please demonstrate how AzureStorageAttachmentConfigurationExtensions.DefaultSasTokenValidationTime would help with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SeanFeldman Sorry, I didn't catch that you specifically meant DefaultSasTokenValidationTime

I agree that making DefaultSasTokenValidationTime public could be a bit much. It just made sense to me to make all default values public in case there would be a use case for them. In my particular case, I only need DefaultMessagePropertyToIdentitySasUri.

I guess you would rather leave DefaultSasTokenValidationTime internal for now, and then only expose it when it's absolutely needed?

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, I've been trained over the time not to reveal anything that is not absolutely necessary. Once it's public, you need to worry about deprecation and migration. When it stays internal, can do whatever is needed with it.

I would suggest removing that bit only. It's still good to mention the default value in the documentation for readers to have an idea. Additionally, some XML documentation can be added to the code, on the parameter, mentioning the default value here:

/// <param name="sasTokenValidationTime">The time blob SAS URI is valid for.</param>

Copy link
Owner

Choose a reason for hiding this comment

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

@sorenhansen, will you do the update or should I?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SeanFeldman I'll do the update. Just been busy the last few days 🙂

I plan on doing it later today

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SeanFeldman I've updated the code, making DefaultSasTokenValidationTime internal again, and documenting the default value in the AzureStorageAttachmentConfigurationExtensions.WithBlobSasUri method.

Copy link
Owner

Choose a reason for hiding this comment

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

Thank you. I have reviewed and left a comment.
Sorry for nitpicking. Don't want to release your good changes without ensuring we're not causing more work to the users.

Copy link
Contributor Author

@sorenhansen sorenhansen Apr 17, 2020

Choose a reason for hiding this comment

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

You're not at all nitpicking 🙂
When I made DefaultMessagePropertyToIdentitySasUri public, I was a bit unhappy with it being in another class than the other constants, so I'm glad you pushed me to refactor it.

I've updated the PR with your proposed changes. I've left DefaultSasTokenValidationTime in AzureStorageAttachmentConfigurationExtensions as it's still internal

@SeanFeldman SeanFeldman added this to the 6.2.0 milestone Apr 15, 2020
- Document default value in constructor.
@SeanFeldman
Copy link
Owner

Copy link
Owner

@SeanFeldman SeanFeldman left a comment

Choose a reason for hiding this comment

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

While I've reviewed the code, I have realized that API wise it's awkward to have these constants that logically belong to the same group , to be spread across several types. This is what it looks from the user perspective:

image

Would be weird to access AzureStorageAttachmentConfigurationExtensions for one constant and AzureStorageAttachmentConfiguration for another two.

Perhaps those should be united under AzureStorageAttachmentConfigurationConstants in the root namespace Microsoft.Azure.ServiceBus? That way it's not hidden, will be side-by-side with the AzureStorageAttachmentConfiguration which is used anyways, and will be easily discoverable.

@SeanFeldman
Copy link
Owner

internal static TimeSpan DefaultSasTokenValidationTime = TimeSpan.FromDays(7);
/// <summary>
/// Default time the blob SAS URI is valid for.
/// </summary>
Copy link
Owner

Choose a reason for hiding this comment

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

This comment probably can go away

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

@SeanFeldman
Copy link
Owner

@SeanFeldman SeanFeldman self-requested a review April 17, 2020 20:17
@SeanFeldman SeanFeldman merged commit 2a22067 into SeanFeldman:develop Apr 17, 2020
@SeanFeldman
Copy link
Owner

Thank you, @sorenhansen!

@sorenhansen sorenhansen deleted the public-default-settings branch April 17, 2020 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants