public Task <GrpcService> Locate(string serviceName, bool lookupParameters) { if (string.IsNullOrWhiteSpace(serviceName)) { throw new ArgumentNullException(nameof(serviceName)); } // get name of service to resolve var name = new ServiceDnsName { Domain = ServiceDomain, ServiceName = serviceName, Protocol = "grpc", DnsName = string.IsNullOrEmpty(ServiceDomain) ? serviceName.ToLowerInvariant() : $"{serviceName.ToLowerInvariant()}._grpc._tcp.{ServiceDomain}" }; // build lookup object var serviceLookup = GrpcServiceLookup.Create(lookupParameters); serviceLookup.Factory = GrpcServiceFactory; serviceLookup.Name = name; // preform lookup and return return(Locate(name, serviceLookup.LocateFunction)); }
public override Task <KafkaService> Locate(string serviceName) { string longName; if (string.IsNullOrWhiteSpace(serviceName)) { longName = serviceName = "_kafka"; } else { longName = $"{serviceName.ToLowerInvariant()}._kafka"; } // get name of service to resolve ServiceDnsName name = new ServiceDnsName { Domain = ServiceDomain, ServiceName = serviceName, Protocol = "kafka", DnsName = string.IsNullOrEmpty(ServiceDomain) ? serviceName.ToLowerInvariant() : $"{longName}._tcp.{ServiceDomain}" }; return(Locate(name, _ => ServiceLookup.SrvTxt(name, KafkaServiceFactory))); }
public Task <DatabaseService> Locate(string serviceName, string protocol) { if (string.IsNullOrWhiteSpace(serviceName)) { throw new ArgumentNullException(nameof(serviceName)); } if (string.IsNullOrWhiteSpace(protocol)) { throw new ArgumentNullException(nameof(protocol)); } // lower-invariant protocol protocol = protocol.ToLowerInvariant(); // get name of service to resolve ServiceDnsName name = new ServiceDnsName { Domain = ServiceDomain, ServiceName = serviceName, Protocol = protocol, DnsName = string.IsNullOrEmpty(ServiceDomain) ? serviceName.ToLowerInvariant() : $"{serviceName.ToLowerInvariant()}._{protocol}._tcp.{ServiceDomain}" }; // locate and return return(Locate(name, _ => ServiceLookup.SrvTxt(name, DbServiceFactory))); }
protected GrpcService GrpcServiceFactory(ServiceDnsName name, IEnumerable <DnsEntry> dnsEntries) { ApplyDnsRandomizer(ref dnsEntries); return(new GrpcService(dnsEntries) { Name = name.ServiceName, Decryptor = { ServiceDomain = name.Domain } }); }
private KafkaService KafkaServiceFactory(ServiceDnsName name, IEnumerable <DnsEntry> dnsEntries) { ApplyDnsRandomizer(ref dnsEntries); return(new KafkaService(dnsEntries) { Name = name.ServiceName, Protocol = name.Protocol, Decryptor = { ServiceDomain = name.Domain } }); }
public Task <DatabaseService> Locate(DatabaseProtocol protocol) { // lower-invariant protocol & service name string protocolName = protocol.ToString().ToLowerInvariant(); string serviceName = $"_{protocolName}"; // get name of service to resolve ServiceDnsName name = new ServiceDnsName { Domain = ServiceDomain, ServiceName = serviceName, Protocol = protocolName, DnsName = string.IsNullOrEmpty(ServiceDomain) ? serviceName.ToLowerInvariant() : $"{serviceName.ToLowerInvariant()}._tcp.{ServiceDomain}" }; // locate and return return(Locate(name, _ => ServiceLookup.SrvTxt(name, DbServiceFactory))); }
public override Task <WebApiService> Locate(string serviceName) { if (string.IsNullOrWhiteSpace(serviceName)) { throw new ArgumentNullException(nameof(serviceName)); } // get name of service to resolve ServiceDnsName name = new ServiceDnsName { Domain = ServiceDomain, ServiceName = serviceName, Protocol = "http", DnsName = string.IsNullOrEmpty(ServiceDomain) ? serviceName.ToLowerInvariant() : $"{serviceName.ToLowerInvariant()}._http._tcp.{ServiceDomain}" }; return(Locate(name, _ => ServiceLookup.SrvTxt(name, WebApiServiceFactory))); }
public Task <GenericService> Locate(string serviceName, IpProtocol protocol) { if (string.IsNullOrWhiteSpace(serviceName)) { throw new ArgumentNullException(nameof(serviceName)); } // get name of service to resolve string sProtocol = protocol.ToString().ToLowerInvariant(); ServiceDnsName name = new ServiceDnsName { Domain = ServiceDomain, ServiceName = serviceName, Protocol = sProtocol, DnsName = string.IsNullOrEmpty(ServiceDomain) ? serviceName.ToLowerInvariant() : $"{serviceName.ToLowerInvariant()}._{sProtocol}.{ServiceDomain}" }; return(Locate(name, _ => ServiceLookup.SrvTxt(name, MyServiceFactory))); }