NServiceBus icon indicating copy to clipboard operation
NServiceBus copied to clipboard

Add IsSendOnly() extension to avoid the magic string

Open ejfn opened this issue 3 years ago • 3 comments
trafficstars

Hi,

Can we adopt this extension in the core package, so that I don't have to deal with the magic string "Endpoint.SendOnly" in the code?

https://github.com/Particular/NServiceBus.Persistence.Sql/blob/master/src/AcceptanceTestHelper/EndpointConfigurationExtensions.cs

ejfn avatar Jul 26 '22 03:07 ejfn

Hi @ericvan76,

Shouldn't be too hard, but to make sure we get the right API surface: can you please expand on what you're trying to achieve? Are you wanting to determine if an endpoint is running in send only mode? Or something else?

WilliamBZA avatar Jul 26 '22 07:07 WilliamBZA

Hi @WilliamBZA ,

Yes, we introduced a feature, and we also have some EndpointConfiguration validation code that ensures that feature should be enabled in certain circumstances, but we don't want to check SendOnly endpoints.

Currently we're doing exactly the same thing as this, but not quite happy with the magic string which is well-known by a 3rd party, although it would be unlikely changed.

It's an extension on the EndpointConfiguration, we use it to check something before the endpoint starts.

public static bool IsSendOnly(this EndpointConfiguration configuration)
{
    return configuration.GetSettings().Get<bool>("Endpoint.SendOnly");
}

Hope this helps.

ejfn avatar Jul 26 '22 10:07 ejfn

Thanks, that helps. I've tagged this as an improvement. Once V8 is released we will start looking at making these kinds of improvements again.

WilliamBZA avatar Jul 27 '22 07:07 WilliamBZA