[Discussion] Service Bus - Track 2 - Methods to create senders/receivers should use the verb create, not get
See original GitHub issueThe intent of this issue is to solicit feedback from the team and the community in advance of the GA of the next major version of the Service Bus library (which will follow several Preview releases). As a reference, the .NET Azure SDK guidelines can be found here: https://azure.github.io/azure-sdk/dotnet_introduction.html Terminology: Track 0 refers to the WindowsAzure.ServiceBus library Track 1 refers to the Microsoft.Azure.ServiceBus library Track 2 refers to the new library, Azure.Messaging.ServiceBus, we are working on releasing.
We have the below methods on the ServiceBusClient
in the first Preview of the Track 2 library to create senders and receivers
- GetSender
- GetReceiver
- GetDeadletterReceiver
- GetSessionReceiverAsync
I’d like to propose that these methods use the create
verb instead for the following reasons
- These methods do not “get” anything from the service, rather they create objects that represent an AMQP link to the service.
- At every invocation, these methods return a new sender/receiver that represent a new AMQP link. The
get
verb would imply that you get the same thing at every invocation - AMQP links are finite resources. It should be clear to the user that its on them to clean up senders/receivers and use them responsibly
- At any given point in time, we can have only 1 receiver for a given session Id. the name
GetSessionReceiverAsync()
suggests I am getting the same receiver, but in reality on second invocation, I get an error because the new receiver cannot get a lock on the session. Since when do “getter” like function throw error that I am asking for the same thing again? - The “get” verb on methods that create sub clients as per the guidelines (like we followed for Storage with
GetAppendBlobClient
) make sense when the client is a stateless object with helpful methods and nothing actually gets created on the service. In our case, we have links being created connecting the client & service & authentication being carried out.
cc @bterlson, @KrzysztofCwalina, @JoshLove-msft, @jsquire, @ShivangiReja, @AlexGhiondea
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
This can be closed right?
I like changing these methods to Create. The methods have significant side effects and the returned objects should be disposed. Create makes it more clear.