public void OnlyTheLastNsqdInstanceIsUsed(string connectionString) { var options = ConsumerOptions.Parse(connectionString); Assert.Equal(0, options.LookupEndPoints.Count); Assert.Equal(new DnsEndPoint("foo", 123), options.NsqEndPoint); }
public void ParsingTakesTheLastOfRepeatedFields() { var connectionString = "foo:123; clientid = FIRST; clientid = SECOND; clientid = THIRD"; var options = ConsumerOptions.Parse(connectionString); Assert.Equal("THIRD", options.ClientId); }
public void NsqdInstancesAreIgnoredIfLookupdIsProvided() { var connectionString = "foo:123; lookupd = bar:456; nsqd = baz:789; clientid=HelloWorld;"; var options = ConsumerOptions.Parse(connectionString); Assert.Null(options.NsqEndPoint); Assert.Equal(2, options.LookupEndPoints.Count); }
public void ParsingIsCaseSpaceAndSemiColonInsensitive(string connectionString) { var options = ConsumerOptions.Parse(connectionString); Assert.Equal("ABC", options.Channel); Assert.Equal("123", options.Topic); Assert.Equal("HelloWorld", options.ClientId); }
public void ParsingGetsAllFields() { var connectionString = "foo:123; channel=abc; clientId=def; hostname=ghi; reconnectionDelay=55; reconnectionMaxDelay=66; topic=foobar"; var options = ConsumerOptions.Parse(connectionString); Assert.Equal("abc", options.Channel); Assert.Equal("def", options.ClientId); Assert.Equal("ghi", options.HostName); Assert.Equal(TimeSpan.FromSeconds(55), options.ReconnectionDelay); Assert.Equal(TimeSpan.FromSeconds(66), options.ReconnectionMaxDelay); Assert.Equal("foobar", options.Topic); }
void ConnectButton_Click(object sender, EventArgs e) { var connectionString = ConnectionString.Text; var options = ConsumerOptions.Parse(connectionString); _nsq = new NsqLookupConsumer(options); _nsq.DiscoveryCompleted += _nsq_DiscoveryCompleted; _nsq.InternalMessages += _nsq_InternalMessages; _nsq.Connect(async msg => { await c_MessageReceived(msg); await msg.FinishAsync(); }); }
public void AllLookupInstancesAreUsed(string connectionString) { var options = ConsumerOptions.Parse(connectionString); var expectedEndPoints = new DnsEndPoint[] { new DnsEndPoint("foo", 123), new DnsEndPoint("bar", 456), new DnsEndPoint("baz", 789), }; Assert.Equal("HelloWorld", options.ClientId); Assert.Equal(expectedEndPoints.Length, options.LookupEndPoints.Count); Assert.All(options.LookupEndPoints, ep => Assert.True(expectedEndPoints.Contains(ep))); }
void ConnectButton_Click(object sender, EventArgs e) { var host = Host.Text; var port = int.Parse(Port.Text); var options = ConsumerOptions.Parse(string.Format("nsqd={0}:{1}", host, port)); options.Topic = TopicTextBox.Text; options.Channel = ChannelTextBox.Text; _nsq = new NsqTcpConnection(new DnsEndPoint(host, port), options); _nsq.InternalMessages += _nsq_InternalMessages; _nsq.Connect(async msg => { await c_MessageReceived(msg); await msg.FinishAsync(); }); }