< 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: 1986_28452893481
Line coverage
91%
Covered lines: 44
Uncovered lines: 4
Coverable lines: 48
Total lines: 116
Line coverage: 91.6%
Branch coverage
83%
Covered branches: 15
Total branches: 18
Branch coverage: 83.3%
Method coverage
100%
Covered methods: 11
Fully covered methods: 10
Total methods: 11
Method coverage: 100%
Full method coverage: 90.9%

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_MaxOutstandingPongs()100%11100%
set_MaxOutstandingPongs(...)100%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    {
 76917        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    {
 76936        get => _initialStreamWindowSize;
 2337        set => _initialStreamWindowSize =
 2338            value < 1024 ?
 2339            throw new ArgumentException(
 2340                $"The {nameof(InitialStreamWindowSize)} value cannot be less than 1 KB.",
 2341                nameof(value)) :
 2342            value;
 43    }
 44
 45    /// <summary>Gets or sets the maximum number of Pong frames that can be queued for sending. A Pong frame is queued
 46    /// for sending when a Ping frame is received, and remains queued until it is written to the underlying duplex
 47    /// connection. The connection is aborted when a Ping frame is received while this limit is reached; this protects
 48    /// against a peer that doesn't read from the connection but keeps sending Ping frames, which would otherwise
 49    /// queue Pong frame writes without limit.</summary>
 50    /// <value>The maximum number of Pong frames queued for sending. It can't be less than <c>1</c>. Defaults to
 51    /// <c>100</c>.</value>
 52    public int MaxOutstandingPongs
 53    {
 77054        get => _maxOutstandingPongs;
 255        set => _maxOutstandingPongs =
 256            value < 1 ?
 257            throw new ArgumentException(
 258                $"The {nameof(MaxOutstandingPongs)} value cannot be less than 1.",
 259                nameof(value)) :
 260            value;
 61    }
 62
 63    /// <summary>Gets or sets the maximum stream frame size in bytes.</summary>
 64    /// <value>The maximum stream frame size in bytes. It can't be less than <c>1024</c> or greater than
 65    /// <c>16,777,215</c> (2^24 - 1). Defaults to <c>32,768</c>.</value>
 66    public int MaxStreamFrameSize
 67    {
 76968        get => _maxStreamFrameSize;
 469        set => _maxStreamFrameSize =
 470            value < 1024 ?
 471            throw new ArgumentException(
 472                $"The {nameof(MaxStreamFrameSize)} value cannot be less than 1 KB.",
 473                nameof(value)) :
 474            value > MaxStreamFrameSizeCeiling ?
 475            throw new ArgumentException(
 476                $"The {nameof(MaxStreamFrameSize)} value cannot be larger than {MaxStreamFrameSizeCeiling}.",
 477                nameof(value)) :
 478            value;
 79    }
 80
 81    /// <summary>Gets or sets the per-connection pause writer threshold. It defines the maximum amount of data that
 82    /// Slic buffers locally on the connection's outbound pipe before
 83    /// <see cref="System.IO.Pipelines.PipeWriter.FlushAsync" /> on the underlying pipe starts blocking. This bounds the
 84    /// memory used by the connection's outbound buffering when a peer is slow or not reading.</summary>
 85    /// <value>The pause writer threshold in bytes. Set to <c>0</c> to disable this flow control mechanism. Otherwise,
 86    /// it can't be less than <c>1</c> KB. Defaults to <c>64</c> KB (the <see cref="System.IO.Pipelines.Pipe" />
 87    /// default).</value>
 88    // The default specified by System.IO.Pipelines.PipeOptions.
 160589    public int PauseWriterThreshold { get; set => field = ValidatePauseWriterThreshold(value); } = 65_536;
 90
 91    // Upper bound on MaxStreamFrameSize (local and peer-advertised). Matches HTTP/2's SETTINGS_MAX_FRAME_SIZE
 92    // ceiling. Larger frames worsen head-of-line blocking across multiplexed streams without improving
 93    // throughput at any realistic link speed.
 94    internal const int MaxStreamFrameSizeCeiling = 16_777_215;
 95
 96    private static int ValidatePauseWriterThreshold(int value) =>
 1697        value < 0 ?
 1698            throw new ArgumentException(
 1699                $"The {nameof(PauseWriterThreshold)} value cannot be negative.",
 16100                nameof(value)) :
 16101            value > 0 && value < 1024 ?
 16102            throw new ArgumentException(
 16103                $"The {nameof(PauseWriterThreshold)} value cannot be less than 1 KB unless it is 0.",
 16104                nameof(value)) :
 16105            value;
 106
 107    // We use the HTTP/2 maximum window size (2GB).
 108    internal const int MaxWindowSize = int.MaxValue;
 109
 817110    private TimeSpan _idleTimeout = TimeSpan.FromSeconds(30);
 111
 112    // The default specified in the HTTP/2 specification.
 817113    private int _initialStreamWindowSize = 65_536;
 817114    private int _maxOutstandingPongs = 100;
 817115    private int _maxStreamFrameSize = 32_768;
 116}