private string GetBrokerServiceUrl(CommandLookupTopicResponse response) { var hasBrokerServiceUrl = !string.IsNullOrEmpty(response.BrokerServiceUrl); var hasBrokerServiceUrlTls = !string.IsNullOrEmpty(response.BrokerServiceUrlTls); switch (_encryptionPolicy) { case EncryptionPolicy.EnforceEncrypted: if (!hasBrokerServiceUrlTls) { throw new ConnectionSecurityException("Cannot enforce encrypted connections. The lookup topic response from broker gave no secure alternative."); } return(response.BrokerServiceUrlTls); case EncryptionPolicy.EnforceUnencrypted: if (!hasBrokerServiceUrl) { throw new ConnectionSecurityException("Cannot enforce unencrypted connections. The lookup topic response from broker gave no unsecure alternative."); } return(response.BrokerServiceUrl); case EncryptionPolicy.PreferEncrypted: return(hasBrokerServiceUrlTls ? response.BrokerServiceUrlTls : response.BrokerServiceUrl); default: return(hasBrokerServiceUrl ? response.BrokerServiceUrl : response.BrokerServiceUrlTls); } }
public LookupDataResult(CommandLookupTopicResponse result) { BrokerUrl = result.brokerServiceUrl; BrokerUrlTls = result.brokerServiceUrlTls; Authoritative = result.Authoritative; Redirect = result.Response == CommandLookupTopicResponse.LookupType.Redirect; ProxyThroughServiceUrl = result.ProxyThroughServiceUrl; Partitions = -1; Error = result.Error; ErrorMessage = result.Message; }
public static void Throw(this CommandLookupTopicResponse command) => Throw(command.Error, command.Message);