Example #1
0
        static async Task RunClientAsync(RespConnection client, 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 client.SendAsync(frame).ConfigureAwait(false);

                    using var result = await client.ReceiveAsync().ConfigureAwait(false);

                    result.Value.ThrowIfError();

                    if (!result.Value.Equals(expected))
                    {
                        Throw();
                    }
                    // await client.PingAsync();
                }
            }
            else
            {
                using var frames = Replicate(frame, pipelineDepth);
                for (int i = 0; i < pingsPerClient; i++)
                {
                    using var batch = await client.BatchAsync(frames.Value).ConfigureAwait(false);

                    CheckBatchForErrors(batch.Value, expected);
                }
            }
        }
Example #2
0
 private static async PooledValueTask SendAsync(PooledMultiplexer @this, RespConnection connection, IBatchedOperation op, CancellationToken cancellationToken, bool flush)
 {
     Interlocked.Increment(ref @this._opCount);
     using var args = op.ConsumeArgs();
     await connection.SendAsync(RespValue.CreateAggregate(RespType.Array, args.Value), cancellationToken, flush).ConfigureAwait(false);
 }