Repository navigation
Expand file tree
/
Copy pathConnectionSettings.cs
More file actions
195 lines (183 loc) · 8.54 KB
/
Copy pathConnectionSettings.cs
File metadata and controls
195 lines (183 loc) · 8.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
using System;
using EventStore.ClientAPI.Common.Utils;
using EventStore.ClientAPI.SystemData;
namespace EventStore.ClientAPI
{
/// <summary>
/// A <see cref="ConnectionSettings"/> object is an immutable representation of the settings for an
/// <see cref="IEventStoreConnection"/>. You can build a <see cref="ConnectionSettings"/> object using
/// a <see cref="ConnectionSettingsBuilder"/>, either via the <see cref="Create"/> method, or via
/// the constructor of <see cref="ConnectionSettingsBuilder"/>.
/// </summary>
public sealed class ConnectionSettings
{
private static readonly Lazy<ConnectionSettings> DefaultSettings = new Lazy<ConnectionSettings>(() => Create(), true);
/// <summary>
/// The default <see cref="ConnectionSettings"></see>.
/// </summary>
public static ConnectionSettings Default { get { return DefaultSettings.Value; } }
/// <summary>
/// Creates a new set of <see cref="ConnectionSettings"/>.
/// </summary>
/// <returns>A <see cref="ConnectionSettingsBuilder"/> you can use to build up a <see cref="ConnectionSettings"/></returns>.
public static ConnectionSettingsBuilder Create()
{
return new ConnectionSettingsBuilder();
}
/// <summary>
/// The <see cref="ILogger"/> that this connection will use.
/// </summary>
public readonly ILogger Log;
/// <summary>
/// Whether to use excessive logging of <see cref="EventStoreConnection"/> internal logic.
/// </summary>
public readonly bool VerboseLogging;
/// <summary>
/// The maximum number of outstanding items allowed in the queue.
/// </summary>
public readonly int MaxQueueSize;
/// <summary>
/// The maximum number of allowed asynchronous operations to be in process.
/// </summary>
public readonly int MaxConcurrentItems;
/// <summary>
/// The maximum number of retry attempts.
/// </summary>
public readonly int MaxRetries;
/// <summary>
/// The maximum number of times to allow for reconnection.
/// </summary>
public readonly int MaxReconnections;
/// <summary>
/// Whether to require EventStore to refuse serving read or write request if it is not master.
/// </summary>
public readonly bool RequireMaster;
/// <summary>
/// The amount of time to delay before attempting to reconnect.
/// </summary>
public readonly TimeSpan ReconnectionDelay;
/// <summary>
/// The amount of time before an operation is considered to have timed out.
/// </summary>
public readonly TimeSpan OperationTimeout;
/// <summary>
/// The amount of time that timeouts are checked in the system.
/// </summary>
public readonly TimeSpan OperationTimeoutCheckPeriod;
/// <summary>
/// The <see cref="UserCredentials"/> to use for operations where other <see cref="UserCredentials"/> are not explicitly supplied.
/// </summary>
public readonly UserCredentials DefaultUserCredentials;
/// <summary>
/// Whether the connection is encrypted using SSL.
/// </summary>
public readonly bool UseSslConnection;
/// <summary>
/// The host name of the server expected on the SSL certificate.
/// </summary>
public readonly string TargetHost;
/// <summary>
/// Whether to validate the server SSL certificate.
/// </summary>
public readonly bool ValidateServer;
/// <summary>
/// Whether to raise an error if no response is received from the server for an operation.
/// </summary>
public readonly bool FailOnNoServerResponse;
/// <summary>
/// The interval at which to send heartbeat messages.
/// </summary>
public readonly TimeSpan HeartbeatInterval;
/// <summary>
/// The interval after which an unacknowledged heartbeat will cause the connection to be considered faulted and disconnect.
/// </summary>
public readonly TimeSpan HeartbeatTimeout;
/// <summary>
/// The DNS name to use for discovering endpoints.
/// </summary>
public readonly string ClusterDns;
/// <summary>
/// The maximum number of attempts for discovering endpoints.
/// </summary>
public readonly int MaxDiscoverAttempts;
/// <summary>
/// The well-known endpoint on which cluster managers are running.
/// </summary>
public readonly int ExternalGossipPort;
/// <summary>
/// Endpoints for seeding gossip if not using DNS.
/// </summary>
public readonly GossipSeed[] GossipSeeds;
/// <summary>
/// Timeout for cluster gossip.
/// </summary>
public readonly TimeSpan GossipTimeout;
/// <summary>
/// Whether to randomly choose a node that's alive from the known nodes.
/// </summary>
public readonly bool PreferRandomNode;
/// <summary>
/// The interval after which a client will time out during connection.
/// </summary>
public readonly TimeSpan ClientConnectionTimeout;
internal ConnectionSettings(ILogger log,
bool verboseLogging,
int maxQueueSize,
int maxConcurrentItems,
int maxRetries,
int maxReconnections,
bool requireMaster,
TimeSpan reconnectionDelay,
TimeSpan operationTimeout,
TimeSpan operationTimeoutCheckPeriod,
UserCredentials defaultUserCredentials,
bool useSslConnection,
string targetHost,
bool validateServer,
bool failOnNoServerResponse,
TimeSpan heartbeatInterval,
TimeSpan heartbeatTimeout,
TimeSpan clientConnectionTimeout,
string clusterDns,
GossipSeed[] gossipSeeds,
int maxDiscoverAttempts,
int externalGossipPort,
TimeSpan gossipTimeout,
bool preferRandomNode)
{
Ensure.NotNull(log, "log");
Ensure.Positive(maxQueueSize, "maxQueueSize");
Ensure.Positive(maxConcurrentItems, "maxConcurrentItems");
if (maxRetries < -1)
throw new ArgumentOutOfRangeException("maxRetries", string.Format("maxRetries value is out of range: {0}. Allowed range: [-1, infinity].", maxRetries));
if (maxReconnections < -1)
throw new ArgumentOutOfRangeException("maxReconnections", string.Format("maxReconnections value is out of range: {0}. Allowed range: [-1, infinity].", maxRetries));
if (useSslConnection)
Ensure.NotNullOrEmpty(targetHost, "targetHost");
Log = log;
VerboseLogging = verboseLogging;
MaxQueueSize = maxQueueSize;
MaxConcurrentItems = maxConcurrentItems;
MaxRetries = maxRetries;
MaxReconnections = maxReconnections;
RequireMaster = requireMaster;
ReconnectionDelay = reconnectionDelay;
OperationTimeout = operationTimeout;
OperationTimeoutCheckPeriod = operationTimeoutCheckPeriod;
ClientConnectionTimeout = clientConnectionTimeout;
DefaultUserCredentials = defaultUserCredentials;
UseSslConnection = useSslConnection;
TargetHost = targetHost;
ValidateServer = validateServer;
FailOnNoServerResponse = failOnNoServerResponse;
HeartbeatInterval = heartbeatInterval;
HeartbeatTimeout = heartbeatTimeout;
ClusterDns = clusterDns;
GossipSeeds = gossipSeeds;
MaxDiscoverAttempts = maxDiscoverAttempts;
ExternalGossipPort = externalGossipPort;
GossipTimeout = gossipTimeout;
PreferRandomNode = preferRandomNode;
}
}
}