< Summary

Information
Class: IceRpc.Transports.Slic.SlicTransportOptions
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Slic/SlicTransportOptions.cs
Tag: 1856_27024993493
Line coverage
90%
Covered lines: 36
Uncovered lines: 4
Coverable lines: 40
Total lines: 97
Line coverage: 90%
Branch coverage
81%
Covered branches: 13
Total branches: 16
Branch coverage: 81.2%
Method coverage
100%
Covered methods: 9
Fully covered methods: 8
Total methods: 9
Method coverage: 100%
Full method coverage: 88.8%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IdleTimeout()100%11100%
set_IdleTimeout(...)75%6450%
get_InitialStreamWindowSize()100%11100%
set_InitialStreamWindowSize(...)50%22100%
get_MaxStreamFrameSize()100%11100%
set_MaxStreamFrameSize(...)75%44100%
get_PauseWriterThreshold()100%11100%
ValidatePauseWriterThreshold(...)100%66100%
.ctor()100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Slic/SlicTransportOptions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3namespace IceRpc.Transports.Slic;
 4
 5/// <summary>A property bag used to configure a <see cref="SlicClientTransport" /> or
 6/// <see cref="SlicServerTransport" />.</summary>
 7public sealed record class SlicTransportOptions
 8{
 9    /// <summary>Gets or sets the idle timeout. This timeout is used to monitor the transport connection health. If no
 10    /// data is received within the idle timeout period, the transport connection is aborted. The effective idle timeout
 11    /// is negotiated with the peer: use <see cref="Timeout.InfiniteTimeSpan" /> to defer to the peer's idle timeout.
 12    /// Idle timeout monitoring is disabled only when both sides use <see cref="Timeout.InfiniteTimeSpan" />.</summary>
 13    /// <value>The idle timeout. It must be positive or <see cref="Timeout.InfiniteTimeSpan" />.
 14    /// Defaults to <c>30</c> s.</value>
 15    public TimeSpan IdleTimeout
 16    {
 75317        get => _idleTimeout;
 18        set
 619        {
 620            if (value != Timeout.InfiniteTimeSpan && value <= TimeSpan.Zero)
 021            {
 022                throw new ArgumentException(
 023                    $"The {nameof(IdleTimeout)} value must be positive or Timeout.InfiniteTimeSpan.",
 024                    nameof(value));
 25            }
 626            _idleTimeout = value;
 627        }
 28    }
 29
 30    /// <summary>Gets or sets the initial stream window size. It defines the initial size of the stream receive buffer
 31    /// for data that has not been consumed yet by the application. When this buffer is full the sender should stop
 32    /// sending additional data.</summary>
 33    /// <value>The initial window size in bytes. It can't be less than <c>1</c> KB. Defaults to <c>64</c> KB.</value>
 34    public int InitialStreamWindowSize
 35    {
 75336        get => _initialStreamWindowSize;
 2037        set => _initialStreamWindowSize =
 2038            value < 1024 ?
 2039            throw new ArgumentException(
 2040                $"The {nameof(InitialStreamWindowSize)} value cannot be less than 1 KB.",
 2041                nameof(value)) :
 2042            value;
 43    }
 44
 45    /// <summary>Gets or sets the maximum stream frame size in bytes.</summary>
 46    /// <value>The maximum stream frame size in bytes. It can't be less than <c>1024</c> or greater than
 47    /// <c>16,777,215</c> (2^24 - 1). Defaults to <c>32,768</c>.</value>
 48    public int MaxStreamFrameSize
 49    {
 75350        get => _maxStreamFrameSize;
 451        set => _maxStreamFrameSize =
 452            value < 1024 ?
 453            throw new ArgumentException(
 454                $"The {nameof(MaxStreamFrameSize)} value cannot be less than 1 KB.",
 455                nameof(value)) :
 456            value > MaxStreamFrameSizeCeiling ?
 457            throw new ArgumentException(
 458                $"The {nameof(MaxStreamFrameSize)} value cannot be larger than {MaxStreamFrameSizeCeiling}.",
 459                nameof(value)) :
 460            value;
 61    }
 62
 63    /// <summary>Gets or sets the per-connection pause writer threshold. It defines the maximum amount of data that
 64    /// Slic buffers locally on the connection's outbound pipe before
 65    /// <see cref="System.IO.Pipelines.PipeWriter.FlushAsync" /> on the underlying pipe starts blocking. This bounds the
 66    /// memory used by the connection's outbound buffering when a peer is slow or not reading.</summary>
 67    /// <value>The pause writer threshold in bytes. Set to <c>0</c> to disable this flow control mechanism. Otherwise,
 68    /// it can't be less than <c>1</c> KB. Defaults to <c>64</c> KB (the <see cref="System.IO.Pipelines.Pipe" />
 69    /// default).</value>
 70    // The default specified by System.IO.Pipelines.PipeOptions.
 156671    public int PauseWriterThreshold { get; set => field = ValidatePauseWriterThreshold(value); } = 65_536;
 72
 73    // Upper bound on MaxStreamFrameSize (local and peer-advertised). Matches HTTP/2's SETTINGS_MAX_FRAME_SIZE
 74    // ceiling. Larger frames worsen head-of-line blocking across multiplexed streams without improving
 75    // throughput at any realistic link speed.
 76    internal const int MaxStreamFrameSizeCeiling = 16_777_215;
 77
 78    private static int ValidatePauseWriterThreshold(int value) =>
 1379        value < 0 ?
 1380            throw new ArgumentException(
 1381                $"The {nameof(PauseWriterThreshold)} value cannot be negative.",
 1382                nameof(value)) :
 1383            value > 0 && value < 1024 ?
 1384            throw new ArgumentException(
 1385                $"The {nameof(PauseWriterThreshold)} value cannot be less than 1 KB unless it is 0.",
 1386                nameof(value)) :
 1387            value;
 88
 89    // We use the HTTP/2 maximum window size (2GB).
 90    internal const int MaxWindowSize = int.MaxValue;
 91
 79792    private TimeSpan _idleTimeout = TimeSpan.FromSeconds(30);
 93
 94    // The default specified in the HTTP/2 specification.
 79795    private int _initialStreamWindowSize = 65_536;
 79796    private int _maxStreamFrameSize = 32_768;
 97}