You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by bl...@apache.org on 2020/11/29 21:19:07 UTC
[pulsar-dotpulsar] branch master updated: Make the default values
public. Correct naming. Adding missing ConfigureAwaits.
This is an automated email from the ASF dual-hosted git repository.
blankensteiner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 9bd9ec2 Make the default values public. Correct naming. Adding missing ConfigureAwaits.
9bd9ec2 is described below
commit 9bd9ec2808c54a47ab4b5e6c4c569ad8b6fac491
Author: Daniel Blankensteiner <db...@vmail.dk>
AuthorDate: Sun Nov 29 22:18:53 2020 +0100
Make the default values public.
Correct naming.
Adding missing ConfigureAwaits.
---
src/DotPulsar/ConsumerOptions.cs | 29 ++++++++++++++++++++----
src/DotPulsar/Internal/Crc32C.cs | 16 ++++++-------
src/DotPulsar/Internal/PulsarStream.cs | 10 ++++----
src/DotPulsar/Internal/RequestResponseHandler.cs | 8 +++----
src/DotPulsar/ProducerOptions.cs | 5 +++-
src/DotPulsar/ReaderOptions.cs | 11 +++++++--
6 files changed, 54 insertions(+), 25 deletions(-)
diff --git a/src/DotPulsar/ConsumerOptions.cs b/src/DotPulsar/ConsumerOptions.cs
index 5422d6f..a07d529 100644
--- a/src/DotPulsar/ConsumerOptions.cs
+++ b/src/DotPulsar/ConsumerOptions.cs
@@ -19,11 +19,30 @@ namespace DotPulsar
/// </summary>
public sealed class ConsumerOptions
{
- internal const SubscriptionInitialPosition DefaultInitialPosition = SubscriptionInitialPosition.Latest;
- internal const uint DefaultMessagePrefetchCount = 1000;
- internal const int DefaultPriorityLevel = 0;
- internal const bool DefaultReadCompacted = false;
- internal const SubscriptionType DefaultSubscriptionType = SubscriptionType.Exclusive;
+ /// <summary>
+ /// The default initial position.
+ /// </summary>
+ public static readonly SubscriptionInitialPosition DefaultInitialPosition = SubscriptionInitialPosition.Latest;
+
+ /// <summary>
+ /// The default message prefetch count.
+ /// </summary>
+ public static readonly uint DefaultMessagePrefetchCount = 1000;
+
+ /// <summary>
+ /// The default priority level.
+ /// </summary>
+ public static readonly int DefaultPriorityLevel = 0;
+
+ /// <summary>
+ /// The default of whether to read compacted.
+ /// </summary>
+ public static readonly bool DefaultReadCompacted = false;
+
+ /// <summary>
+ /// The default subscription type.
+ /// </summary>
+ public static readonly SubscriptionType DefaultSubscriptionType = SubscriptionType.Exclusive;
public ConsumerOptions(string subscriptionName, string topic)
{
diff --git a/src/DotPulsar/Internal/Crc32C.cs b/src/DotPulsar/Internal/Crc32C.cs
index 2dfac40..63d641a 100644
--- a/src/DotPulsar/Internal/Crc32C.cs
+++ b/src/DotPulsar/Internal/Crc32C.cs
@@ -18,13 +18,13 @@ namespace DotPulsar.Internal
public static class Crc32C
{
- private const uint Generator = 0x82F63B78u;
+ private const uint _generator = 0x82F63B78u;
- private static readonly uint[] Lookup;
+ private static readonly uint[] _lookup;
static Crc32C()
{
- Lookup = new uint[16 * 256];
+ _lookup = new uint[16 * 256];
for (uint i = 0; i < 256; i++)
{
@@ -33,9 +33,9 @@ namespace DotPulsar.Internal
for (var j = 0; j < 16; j++)
{
for (var k = 0; k < 8; k++)
- entry = (entry & 1) == 1 ? Generator ^ (entry >> 1) : entry >> 1;
+ entry = (entry & 1) == 1 ? _generator ^ (entry >> 1) : entry >> 1;
- Lookup[j * 256 + i] = entry;
+ _lookup[j * 256 + i] = entry;
}
}
}
@@ -58,16 +58,16 @@ namespace DotPulsar.Internal
if (!readingBlock)
{
- checksum = Lookup[(byte) (checksum ^ currentByte)] ^ (checksum >> 8);
+ checksum = _lookup[(byte) (checksum ^ currentByte)] ^ (checksum >> 8);
continue;
}
var offSetBase = offset * 256;
if (offset > 11)
- block[offset] = Lookup[offSetBase + ((byte) (checksum >> (8 * (15 - offset))) ^ currentByte)];
+ block[offset] = _lookup[offSetBase + ((byte) (checksum >> (8 * (15 - offset))) ^ currentByte)];
else
- block[offset] = Lookup[offSetBase + currentByte];
+ block[offset] = _lookup[offSetBase + currentByte];
--remaningBytes;
diff --git a/src/DotPulsar/Internal/PulsarStream.cs b/src/DotPulsar/Internal/PulsarStream.cs
index 6b0f598..01a6062 100644
--- a/src/DotPulsar/Internal/PulsarStream.cs
+++ b/src/DotPulsar/Internal/PulsarStream.cs
@@ -28,8 +28,8 @@ namespace DotPulsar.Internal
public sealed class PulsarStream : IPulsarStream
{
- private const long PauseAtMoreThan10Mb = 10485760;
- private const long ResumeAt5MbOrLess = 5242881;
+ private const long _pauseAtMoreThan10Mb = 10485760;
+ private const long _resumeAt5MbOrLess = 5242881;
private readonly Stream _stream;
private readonly PipeReader _reader;
@@ -39,7 +39,7 @@ namespace DotPulsar.Internal
public PulsarStream(Stream stream)
{
_stream = stream;
- var options = new PipeOptions(pauseWriterThreshold: PauseAtMoreThan10Mb, resumeWriterThreshold: ResumeAt5MbOrLess);
+ var options = new PipeOptions(pauseWriterThreshold: _pauseAtMoreThan10Mb, resumeWriterThreshold: _resumeAt5MbOrLess);
var pipe = new Pipe(options);
_reader = pipe.Reader;
_writer = pipe.Writer;
@@ -112,7 +112,7 @@ namespace DotPulsar.Internal
}
finally
{
- await _writer.CompleteAsync();
+ await _writer.CompleteAsync().ConfigureAwait(false);
}
}
@@ -153,7 +153,7 @@ namespace DotPulsar.Internal
}
finally
{
- await _reader.CompleteAsync();
+ await _reader.CompleteAsync().ConfigureAwait(false);
}
}
diff --git a/src/DotPulsar/Internal/RequestResponseHandler.cs b/src/DotPulsar/Internal/RequestResponseHandler.cs
index 42e62df..ae7bdee 100644
--- a/src/DotPulsar/Internal/RequestResponseHandler.cs
+++ b/src/DotPulsar/Internal/RequestResponseHandler.cs
@@ -20,7 +20,7 @@ namespace DotPulsar.Internal
public sealed class RequestResponseHandler : IDisposable
{
- private const string ConnectResponseIdentifier = "Connected";
+ private const string _connectResponseIdentifier = "Connected";
private readonly Awaiter<string, BaseCommand> _responses;
private readonly RequestId _requestId;
@@ -85,12 +85,12 @@ namespace DotPulsar.Internal
private string GetResponseIdentifier(BaseCommand cmd)
=> cmd.CommandType switch
{
- BaseCommand.Type.Connect => ConnectResponseIdentifier,
- BaseCommand.Type.Connected => ConnectResponseIdentifier,
+ BaseCommand.Type.Connect => _connectResponseIdentifier,
+ BaseCommand.Type.Connected => _connectResponseIdentifier,
BaseCommand.Type.Send => $"{cmd.Send.ProducerId}-{cmd.Send.SequenceId}",
BaseCommand.Type.SendError => $"{cmd.SendError.ProducerId}-{cmd.SendError.SequenceId}",
BaseCommand.Type.SendReceipt => $"{cmd.SendReceipt.ProducerId}-{cmd.SendReceipt.SequenceId}",
- BaseCommand.Type.Error => !_requestId.IsPastInitialId() ? ConnectResponseIdentifier : cmd.Error.RequestId.ToString(),
+ BaseCommand.Type.Error => !_requestId.IsPastInitialId() ? _connectResponseIdentifier : cmd.Error.RequestId.ToString(),
BaseCommand.Type.Producer => cmd.Producer.RequestId.ToString(),
BaseCommand.Type.ProducerSuccess => cmd.ProducerSuccess.RequestId.ToString(),
BaseCommand.Type.CloseProducer => cmd.CloseProducer.RequestId.ToString(),
diff --git a/src/DotPulsar/ProducerOptions.cs b/src/DotPulsar/ProducerOptions.cs
index 9d2197b..906b72d 100644
--- a/src/DotPulsar/ProducerOptions.cs
+++ b/src/DotPulsar/ProducerOptions.cs
@@ -19,7 +19,10 @@ namespace DotPulsar
/// </summary>
public sealed class ProducerOptions
{
- internal const ulong DefaultInitialSequenceId = 0;
+ /// <summary>
+ /// The default initial sequence id.
+ /// </summary>
+ public static readonly ulong DefaultInitialSequenceId = 0;
public ProducerOptions(string topic)
{
diff --git a/src/DotPulsar/ReaderOptions.cs b/src/DotPulsar/ReaderOptions.cs
index 2ee644c..4021087 100644
--- a/src/DotPulsar/ReaderOptions.cs
+++ b/src/DotPulsar/ReaderOptions.cs
@@ -19,8 +19,15 @@ namespace DotPulsar
/// </summary>
public sealed class ReaderOptions
{
- internal const uint DefaultMessagePrefetchCount = 1000;
- internal const bool DefaultReadCompacted = false;
+ /// <summary>
+ /// The default message prefetch count.
+ /// </summary>
+ public static readonly uint DefaultMessagePrefetchCount = 1000;
+
+ /// <summary>
+ /// The default of whether to read compacted.
+ /// </summary>
+ public static readonly bool DefaultReadCompacted = false;
public ReaderOptions(MessageId startMessageId, string topic)
{