public PooledMultiplexer(ConfigurationOptions configuration, RespConnectionPoolOptions options) { Configuration = configuration.Clone(); if (configuration.EndPoints.Count != 1) { throw new ArgumentException("A single endpoint is expected", nameof(configuration)); } _pool = new RespConnectionPool(cancellation => ConnectAsync(cancellation), options); }
static async Task RunClientAsync(RespConnectionPool pool, int pingsPerClient, int pipelineDepth, string payload) { var frame = string.IsNullOrEmpty(payload) ? s_ping : RespValue.CreateAggregate(RespType.Array, "PING", payload); var expected = string.IsNullOrEmpty(payload) ? s_pong : RespValue.Create(RespType.BlobString, payload); if (pipelineDepth == 1) { for (int i = 0; i < pingsPerClient; i++) { await pool.CallAsync(frame, result => { result.ThrowIfError(); if (!result.Equals(expected)) { Throw(); } }); // await client.PingAsync(); } } else { using var frames = Replicate(frame, pipelineDepth); for (int i = 0; i < pingsPerClient; i++) { using var batch = await pool.BatchAsync(frames.Value).ConfigureAwait(false); CheckBatchForErrors(batch.Value, expected); } } }