| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | using System.Net.Security; |
| | 4 | |
|
| | 5 | | namespace IceRpc; |
| | 6 | |
|
| | 7 | | /// <summary>Represents a property bag used to configure a <see cref="Server" />.</summary> |
| | 8 | | public sealed record class ServerOptions |
| | 9 | | { |
| | 10 | | /// <summary>Gets or sets the connection options for server connections.</summary> |
| | 11 | | /// <value>The connection options. Defaults to a default constructed <see cref="ConnectionOptions" />.</value> |
| 1054 | 12 | | public ConnectionOptions ConnectionOptions { get; set; } = new(); |
| | 13 | |
|
| | 14 | | /// <summary>Gets or sets the connection establishment timeout for connections accepted by the server.</summary> |
| | 15 | | /// <value>Defaults to <c>10</c> seconds.</value> |
| | 16 | | public TimeSpan ConnectTimeout |
| | 17 | | { |
| 142 | 18 | | get => _connectTimeout; |
| 4 | 19 | | set => _connectTimeout = value != TimeSpan.Zero ? value : |
| 4 | 20 | | throw new ArgumentException($"0 is not a valid value for {nameof(ConnectTimeout)}", nameof(value)); |
| | 21 | | } |
| | 22 | |
|
| | 23 | | /// <summary>Gets or sets the maximum number of accepted server connections. Once the maximum number of connections |
| | 24 | | /// has been reached, the server will refuse any new connections.</summary> |
| | 25 | | /// <value>The maximum number of connections. Defaults to <c>0</c>, meaning unlimited.</value> |
| 156 | 26 | | public int MaxConnections { get; set; } |
| | 27 | |
|
| | 28 | | /// <summary>Gets or sets the maximum number of server connections waiting for connection establishment to complete. |
| | 29 | | /// Once the maximum number of pending connections has been reached, the server will stop accepting new connections |
| | 30 | | /// to ensure that the transport rejects new connections once its connection backlog is full.</summary> |
| | 31 | | /// <value>The maximum number of connection waiting for connection establishment to complete. Defaults to |
| | 32 | | /// <c>100</c>.</value> |
| 286 | 33 | | public int MaxPendingConnections { get; set; } = 100; |
| | 34 | |
|
| | 35 | | /// <summary>Gets or sets the server's address. The server address host is usually an IP address, and it cannot be a |
| | 36 | | /// DNS name.</summary> |
| | 37 | | /// <value>The <see cref="ServerAddress" /> of this <see cref="Server" />. Defaults to a <see cref="ServerAddress" |
| | 38 | | /// /> constructed with <see cref="Protocol.IceRpc" />.</value> |
| 424 | 39 | | public ServerAddress ServerAddress { get; set; } = new(Protocol.IceRpc); |
| | 40 | |
|
| | 41 | | /// <summary>Gets or sets the SSL server authentication options.</summary> |
| | 42 | | /// <value>The SSL server authentication options. When not <see langword="null" />, the server will accept only |
| | 43 | | /// secure connections.</value> |
| 192 | 44 | | public SslServerAuthenticationOptions? ServerAuthenticationOptions { get; set; } |
| | 45 | |
|
| | 46 | | /// <summary>Gets or sets the shutdown timeout. This timeout is used when gracefully shutting down a connection |
| | 47 | | /// managed by the server.</summary> |
| | 48 | | /// <value>Defaults to <c>10</c> seconds.</value> |
| | 49 | | public TimeSpan ShutdownTimeout |
| | 50 | | { |
| 142 | 51 | | get => _shutdownTimeout; |
| 0 | 52 | | set => _shutdownTimeout = value != TimeSpan.Zero ? value : |
| 0 | 53 | | throw new ArgumentException($"0 is not a valid value for {nameof(ShutdownTimeout)}", nameof(value)); |
| | 54 | | } |
| | 55 | |
|
| 142 | 56 | | private TimeSpan _connectTimeout = TimeSpan.FromSeconds(10); |
| 142 | 57 | | private TimeSpan _shutdownTimeout = TimeSpan.FromSeconds(10); |
| | 58 | | } |