Esempio n. 1
0
        internal static async Task WriteAsync(INatsStreamWriter writer, ReadOnlyMemory <char> subject, ReadOnlyMemory <char> replyTo, ReadOnlyMemory <byte> body)
        {
            var bodySize    = body.Length.ToString().AsMemory();
            var preBodySize = 3 + 1 + subject.Length + 1 + (replyTo.Length > 0 ? replyTo.Length + 1 : 0) + bodySize.Length + NatsEncoder.CrlfBytesLen;
            var preBody     = new Memory <byte>(new byte[preBodySize]);

            FillPreBody(preBody.Span, subject.Span, replyTo.Span, bodySize.Span);

            await writer.WriteAsync(preBody, false).ConfigureAwait(false);

            await writer.WriteAsync(body, false).ConfigureAwait(false);

            await writer.WriteAsync(NatsEncoder.CrlfBytes, false).ConfigureAwait(false);
        }
Esempio n. 2
0
        internal static async Task WriteAsync(INatsStreamWriter writer, ReadOnlyMemory <char> subject, ReadOnlyMemory <char> subscriptionId, ReadOnlyMemory <char> queueGroup)
        {
            var trg = new Memory <byte>(new byte[3 + 1 + subject.Length + 1 + (queueGroup.IsEmpty ? 0 : queueGroup.Length + 1) + subscriptionId.Length + NatsEncoder.CrlfBytesLen]);

            Fill(trg.Span, subject.Span, subscriptionId.Span, queueGroup.Span);

            await writer.WriteAsync(trg, false).ConfigureAwait(false);
        }
Esempio n. 3
0
        internal static async Task WriteAsync(INatsStreamWriter writer, ReadOnlyMemory <char> subscriptionId, int?maxMessages = null)
        {
            var maxMessagesString = maxMessages.ToString().AsMemory();
            var trg = new Memory <byte>(new byte[5 + 1 + subscriptionId.Length + (maxMessagesString.IsEmpty ? 0 : maxMessagesString.Length + 1) + NatsEncoder.CrlfBytesLen]);

            Fill(trg.Span, subscriptionId.Span, maxMessagesString.Span);

            await writer.WriteAsync(trg, false).ConfigureAwait(false);
        }
Esempio n. 4
0
 internal static Task WriteAsync(INatsStreamWriter writer)
 => writer.WriteAsync(Bytes, true);