| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | namespace IceRpc.Transports.Coloc; |
| | 4 | |
|
| | 5 | | /// <summary>A property bag used to configure a <see cref="ColocTransport" />.</summary> |
| | 6 | | public sealed record class ColocTransportOptions |
| | 7 | | { |
| | 8 | | /// <summary>Gets or sets the maximum length of the pending connections queue.</summary> |
| | 9 | | /// <value>The maximum queue length. The value cannot be less than <c>1</c>. Defaults to <c>511</c>.</value> |
| | 10 | | public int ListenBacklog |
| | 11 | | { |
| 986 | 12 | | get => _listenBacklog; |
| 14 | 13 | | set => _listenBacklog = value >= 1 ? value : |
| 14 | 14 | | throw new ArgumentOutOfRangeException( |
| 14 | 15 | | nameof(value), |
| 14 | 16 | | $"Invalid value '{value}' for {nameof(ListenBacklog)}, it cannot be less than 1."); |
| | 17 | | } |
| | 18 | |
|
| | 19 | | /// <summary>Gets or sets the number of bytes in the Coloc connection when <see cref="IDuplexConnection.WriteAsync" |
| | 20 | | /// /> starts blocking.</summary> |
| | 21 | | /// <value>The pause writer threshold. The value cannot be less than <c>1</c> KB. Defaults to <c>64</c> KB.</value> |
| | 22 | | public int PauseWriterThreshold |
| | 23 | | { |
| 1993 | 24 | | get => _pauseWriterThreshold; |
| 6 | 25 | | set => _pauseWriterThreshold = value >= 1024 ? value : |
| 6 | 26 | | throw new ArgumentOutOfRangeException( |
| 6 | 27 | | nameof(value), |
| 6 | 28 | | $"Invalid value '{value}' for {nameof(PauseWriterThreshold)}, it cannot be less than 1KB."); |
| | 29 | | } |
| | 30 | |
|
| | 31 | | /// <summary>Gets or sets the number of bytes in the Coloc connection when <see cref="IDuplexConnection.WriteAsync" |
| | 32 | | /// /> stops blocking.</summary> |
| | 33 | | /// <value>The resume writer threshold. The value cannot be less than <c>1</c> KB and cannot be greater than <see |
| | 34 | | /// cref="PauseWriterThreshold"/>. Defaults to <c>32</c> KB.</value> |
| | 35 | | public int ResumeWriterThreshold |
| | 36 | | { |
| 1993 | 37 | | get => _resumeWriterThreshold; |
| 6 | 38 | | set => _resumeWriterThreshold = |
| 6 | 39 | | value < 1024 ? throw new ArgumentOutOfRangeException( |
| 6 | 40 | | nameof(value), |
| 6 | 41 | | $"Invalid value '{value}' for {nameof(ResumeWriterThreshold)}, it cannot be less than 1KB.") : |
| 6 | 42 | | value > _pauseWriterThreshold ? throw new ArgumentException( |
| 6 | 43 | | $"The value of {nameof(ResumeWriterThreshold)} cannot be greater than the value of {nameof(PauseWriterTh |
| 6 | 44 | | nameof(value)) : |
| 6 | 45 | | value; |
| | 46 | | } |
| | 47 | |
|
| 978 | 48 | | private int _listenBacklog = 511; |
| 978 | 49 | | private int _pauseWriterThreshold = 65536; |
| 978 | 50 | | private int _resumeWriterThreshold = 32768; |
| | 51 | | } |