Skip to content

Commit

Permalink
Switch to idiomatic range exceptions
Browse files Browse the repository at this point in the history
Also corrects invalid comparison in MaxInflight (using maxInFlight instead of value)
  • Loading branch information
sixlettervariables committed Sep 8, 2016
1 parent 1f75a23 commit a78a7ec
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions STAN.CLIENT/SubscriptionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,20 @@ internal StanSubscriptionOptions(StanSubscriptionOptions opts)
if (opts == null)
return;

this.ackWait = opts.ackWait;
ackWait = opts.ackWait;

if (opts.durableName != null)
{
this.durableName = new String(opts.durableName.ToCharArray());
this.durableName = string.Copy(opts.durableName);
}

manualAcks = opts.manualAcks;
maxInFlight = opts.maxInFlight;
startAt = opts.startAt;
startSequence = opts.startSequence;
useStartTimeDelta = opts.useStartTimeDelta;

if (opts.startTime != null)
{
startTime = opts.startTime;
}

if (opts.startTimeDelta != null)
{
startTimeDelta = opts.startTimeDelta;
}
startTime = opts.startTime;
startTimeDelta = opts.startTimeDelta;
}

/// <summary>
Expand All @@ -66,15 +58,14 @@ public string DurableName
/// <summary>
/// Controls the number of messages the cluster will have inflight without an ACK.
/// </summary>
public int MaxInflight
public int MaxInflight
{
get { return maxInFlight; }
set
{
if (maxInFlight < 0)
{
throw new ArgumentException("value must be > 0");
}
if (value < 0)
throw new ArgumentOutOfRangeException("value", value, "MaxInflight must be greater than 0");

maxInFlight = value;
}
}
Expand All @@ -85,22 +76,22 @@ public int MaxInflight
/// <remarks>
/// The value must be at least one second.
/// </remarks>
public int AckWait
public int AckWait
{
get { return ackWait; }
set
{
if (value < 1000)
throw new ArgumentException("value cannot be less than 1000");
throw new ArgumentOutOfRangeException("value", value, "AckWait cannot be less than 1000");

ackWait = value;
}
}

/// <summary>
/// Controls the time the cluster will wait for an ACK for a given message.
/// </summary>
public bool ManualAcks
public bool ManualAcks
{
get { return manualAcks; }
set { manualAcks = value; }
Expand All @@ -110,7 +101,7 @@ public bool ManualAcks
/// Optional start sequence number.
/// </summary>
/// <param name="sequence"></param>
public void StartAt(ulong sequence)
public void StartAt(ulong sequence)
{
startAt = StartPosition.SequenceStart;
startSequence = sequence;
Expand All @@ -120,7 +111,7 @@ public void StartAt(ulong sequence)
/// Optional start time.
/// </summary>
/// <param name="time"></param>
public void StartAt(DateTime time)
public void StartAt(DateTime time)
{
useStartTimeDelta = false;
startTime = time;
Expand All @@ -143,7 +134,7 @@ public void StartAt(TimeSpan duration)
/// </summary>
public void StartWithLastReceived()
{
startAt = StartPosition.LastReceived;
startAt = StartPosition.LastReceived;
}

/// <summary>
Expand Down

0 comments on commit a78a7ec

Please sign in to comment.