Esempio n. 1
0
        public SyncProducer(SyncProducerConfig config)
        {
            Logger.Debug("Instantiating Scala Sync Producer");

            this.Config               = config;
            this.blockingChannel      = new BlockingChannel(config.Host, config.Port, BlockingChannel.UseDefaultBufferSize, config.SendBufferBytes, config.RequestTimeoutMs);
            this.BrokerInfo           = string.Format("host_{0}-port_{1}", config.Host, config.Port);
            this.producerRequestStats = ProducerRequestStatsRegistry.GetProducerRequestStats(config.ClientId);
        }
Esempio n. 2
0
 public SimpleConsumer(string host, int port, int soTimeout, int bufferSize, string clientId)
 {
     this.Host       = host;
     this.Port       = port;
     this.SoTimeout  = soTimeout;
     this.BufferSize = bufferSize;
     this.ClientId   = clientId;
     ConsumerConfig.ValidateClientId(clientId);
     this.blockingChannel = new BlockingChannel(this.Host, this.Port, this.BufferSize, BlockingChannel.UseDefaultBufferSize, this.SoTimeout);
     this.fetchRequestAndResponseStats =
         FetchRequestAndResponseStatsRegistry.GetFetchRequestAndResponseStats(clientId);
 }
        public UdpMessagingLoadTests()
        {
            Go(async() => {
                var ch = new BlockingChannel <string>();
                var l  = new AsyncLatch();
                Go(async() => {
                    await l.WaitAsync().ConfigureAwait(false);
                    for (var i = 0; i < 10; i++)
                    {
                        await ch.WriteAsync("asdf").ConfigureAwait(false);
                        await Task.Delay(400).ConfigureAwait(false);
                    }
                }).Forget();
                l.Set();
                for (var i = 0; i < 10; i++)
                {
                    await new Select {
                        Case(Time.After(500), () => {
                            Console.WriteLine("Nay!");
                        }),
                        Case(ch, () => {
                            Console.WriteLine("Yay!");
                        })
                    }.WaitAsync().ConfigureAwait(false);
                }
                while (true)
                {
                    ;
                }
            }).Wait();
            var courierFacades = Util.Generate(
                2,
                i => CourierBuilder.Create()
                .UseUdpTransport()
                .UseTcpServerTransport(21337 + i)
                .BuildAsync().Result);

            Setup(courierFacades);
        }
 public UdpMessagingLoadTests() {
    Go(async () => {
       var ch = new BlockingChannel<string>();
       var l = new AsyncLatch();
       Go(async () => {
          await l.WaitAsync().ConfigureAwait(false);
          for (var i = 0; i < 10; i++) {
             await ch.WriteAsync("asdf").ConfigureAwait(false);
             await Task.Delay(400).ConfigureAwait(false);
          }
       }).Forget();
       l.Set();
       for (var i = 0; i < 10; i++) {
          await new Select {
             Case(Time.After(500), () => {
                Console.WriteLine("Nay!");
             }),
             Case(ch, () => {
                Console.WriteLine("Yay!");
             })
          }.WaitAsync().ConfigureAwait(false);
       }
       while (true) ;
    }).Wait();
    var courierFacades = Util.Generate(
       2,
       i => CourierBuilder.Create()
                          .UseUdpTransport()
                          .UseTcpServerTransport(21337 + i)
                          .BuildAsync().Result);
    Setup(courierFacades);
 }