| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | namespace IceRpc.Transports.Slic; |
| | | 4 | | |
| | | 5 | | /// <summary>A property bag used to configure a <see cref="SlicClientTransport" /> or |
| | | 6 | | /// <see cref="SlicServerTransport" />.</summary> |
| | | 7 | | public 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 | | { |
| | 706 | 17 | | get => _idleTimeout; |
| | | 18 | | set |
| | 6 | 19 | | { |
| | 6 | 20 | | if (value != Timeout.InfiniteTimeSpan && value <= TimeSpan.Zero) |
| | 0 | 21 | | { |
| | 0 | 22 | | throw new ArgumentException( |
| | 0 | 23 | | $"The {nameof(IdleTimeout)} value must be positive or Timeout.InfiniteTimeSpan.", |
| | 0 | 24 | | nameof(value)); |
| | | 25 | | } |
| | 6 | 26 | | _idleTimeout = value; |
| | 6 | 27 | | } |
| | | 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 | | { |
| | 706 | 36 | | get => _initialStreamWindowSize; |
| | 9 | 37 | | set => _initialStreamWindowSize = |
| | 9 | 38 | | value < 1024 ? |
| | 9 | 39 | | throw new ArgumentException( |
| | 9 | 40 | | $"The {nameof(InitialStreamWindowSize)} value cannot be less than 1 KB.", |
| | 9 | 41 | | nameof(value)) : |
| | 9 | 42 | | value > MaxWindowSize ? |
| | 9 | 43 | | throw new ArgumentException( |
| | 9 | 44 | | $"The {nameof(InitialStreamWindowSize)} value cannot be larger than {MaxWindowSize}.", |
| | 9 | 45 | | nameof(value)) : |
| | 9 | 46 | | value; |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary>Gets or sets the maximum stream frame size in bytes.</summary> |
| | | 50 | | /// <value>The maximum stream frame size in bytes. It can't be less than <c>1</c> KB. Defaults to <c>32</c> |
| | | 51 | | /// KB.</value> |
| | | 52 | | public int MaxStreamFrameSize |
| | | 53 | | { |
| | 706 | 54 | | get => _maxStreamFrameSize; |
| | 2 | 55 | | set => _maxStreamFrameSize = value >= 1024 ? value : |
| | 2 | 56 | | throw new ArgumentException( |
| | 2 | 57 | | $"The {nameof(MaxStreamFrameSize)} value cannot be less than 1KB.", |
| | 2 | 58 | | nameof(value)); |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | // We use the HTTP/2 maximum window size (2GB). |
| | | 62 | | internal const int MaxWindowSize = int.MaxValue; |
| | | 63 | | |
| | 750 | 64 | | private TimeSpan _idleTimeout = TimeSpan.FromSeconds(30); |
| | | 65 | | // The default specified in the HTTP/2 specification. |
| | 750 | 66 | | private int _initialStreamWindowSize = 65_536; |
| | 750 | 67 | | private int _maxStreamFrameSize = 32_768; |
| | | 68 | | } |