/// <summary> /// Parses a connection string into a <c>ConsumerOptions</c> instance. /// </summary> /// <param name="connectionString">A semicolon-delimited list of key=value pairs of connection options.</param> /// <returns></returns> public static ConsumerOptions Parse(string connectionString) { var options = new ConsumerOptions(); var parts = ParseIntoSegments(connectionString); if (parts.Contains(LookupdKey)) { foreach (var endPoint in ParseEndPoints(parts[LookupdKey], DefaultLookupdHttpPort)) { options.LookupEndPoints.Add(endPoint); } } else if (parts.Contains(NsqdKey)) { options.NsqEndPoint = ParseEndPoints(parts[NsqdKey], DefaultNsqdTcpPort).Last(); } else { throw new ArgumentException("Must provide either nsqlookupd or nsqd endpoints"); } if (parts.Contains(ClientidKey)) { options.ClientId = parts[ClientidKey].Last(); } if (parts.Contains(HostnameKey)) { options.HostName = parts[HostnameKey].Last(); } if (parts.Contains(LookupperiodKey)) { options.LookupPeriod = TimeSpan.FromSeconds(int.Parse(parts[LookupperiodKey].Last())); } if (parts.Contains(TopicKey)) { options.Topic = parts[TopicKey].Last(); } if (parts.Contains(ChannelKey)) { options.Channel = parts[ChannelKey].Last(); } if (parts.Contains(ReconnectiondelayKey)) { options.ReconnectionDelay = TimeSpan.FromSeconds(int.Parse(parts[ReconnectiondelayKey].Last())); } if (parts.Contains(ReconnectionmaxdelayKey)) { options.ReconnectionMaxDelay = TimeSpan.FromSeconds(int.Parse(parts[ReconnectionmaxdelayKey].Last())); } if (parts.Contains(MessagetimeoutKey)) { options.MessageTimeout = int.Parse(parts[MessagetimeoutKey].Last()); } return(options); }
public NsqTcpConnection(DnsEndPoint endPoint, ConsumerOptions options) : this(endPoint, options, new ExponentialBackoffStrategy(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(30))) { }
public NsqLookupConsumer(string connectionString) : this(ConsumerOptions.Parse(connectionString)) { }
public NsqLookupConsumer(string connectionString, ILogger logger) : this(ConsumerOptions.Parse(connectionString), logger) { }
public static INsqConsumer Create(ConsumerOptions options) { return(Create(options, null)); }
public static INsqConsumer Create(string connectionString, ILogger logger) { return(Create(ConsumerOptions.Parse(connectionString), logger)); }
public static INsqConsumer Create(string connectionString) { return(Create(ConsumerOptions.Parse(connectionString))); }