| | 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. |
| | 11 | | /// </summary> |
| | 12 | | /// <value>The idle timeout. Defaults to <c>30</c> s.</value> |
| | 13 | | public TimeSpan IdleTimeout |
| | 14 | | { |
| 1373 | 15 | | get => _idleTimeout; |
| 12 | 16 | | set => _idleTimeout = value != TimeSpan.Zero ? value : |
| 12 | 17 | | throw new ArgumentException( |
| 12 | 18 | | $"The value '0' is not a valid for {nameof(IdleTimeout)} property.", |
| 12 | 19 | | nameof(value)); |
| | 20 | | } |
| | 21 | |
|
| | 22 | | /// <summary>Gets or sets the initial stream window size. It defines the initial size of the stream receive buffer |
| | 23 | | /// for data that has not been consumed yet by the application. When this buffer is full the sender should stop |
| | 24 | | /// sending additional data.</summary> |
| | 25 | | /// <value>The initial window size in bytes. It can't be less than <c>1</c> KB. Defaults to <c>64</c> KB.</value> |
| | 26 | | public int InitialStreamWindowSize |
| | 27 | | { |
| 1373 | 28 | | get => _initialStreamWindowSize; |
| 18 | 29 | | set => _initialStreamWindowSize = |
| 18 | 30 | | value < 1024 ? |
| 18 | 31 | | throw new ArgumentException( |
| 18 | 32 | | $"The {nameof(InitialStreamWindowSize)} value cannot be less than 1 KB.", |
| 18 | 33 | | nameof(value)) : |
| 18 | 34 | | value > MaxWindowSize ? |
| 18 | 35 | | throw new ArgumentException( |
| 18 | 36 | | $"The {nameof(InitialStreamWindowSize)} value cannot be larger than {MaxWindowSize}.", |
| 18 | 37 | | nameof(value)) : |
| 18 | 38 | | value; |
| | 39 | | } |
| | 40 | |
|
| | 41 | | /// <summary>Gets or sets the maximum stream frame size in bytes.</summary> |
| | 42 | | /// <value>The maximum stream frame size in bytes. It can't be less than <c>1</c> KB. Defaults to <c>32</c> |
| | 43 | | /// KB.</value> |
| | 44 | | public int MaxStreamFrameSize |
| | 45 | | { |
| 1373 | 46 | | get => _maxStreamFrameSize; |
| 4 | 47 | | set => _maxStreamFrameSize = value >= 1024 ? value : |
| 4 | 48 | | throw new ArgumentException( |
| 4 | 49 | | $"The {nameof(MaxStreamFrameSize)} value cannot be less than 1KB.", |
| 4 | 50 | | nameof(value)); |
| | 51 | | } |
| | 52 | |
|
| | 53 | | // We use the HTTP/2 maximum window size (2GB). |
| | 54 | | internal const int MaxWindowSize = int.MaxValue; |
| | 55 | |
|
| 1378 | 56 | | private TimeSpan _idleTimeout = TimeSpan.FromSeconds(30); |
| | 57 | | // The default specified in the HTTP/2 specification. |
| 1378 | 58 | | private int _initialStreamWindowSize = 65_536; |
| 1378 | 59 | | private int _maxStreamFrameSize = 32_768; |
| | 60 | | } |