Skip to content

Commit 373888b

Browse files
committed
Added ability to get configuration from config end point
This will help users distribute the load across services
1 parent c81b126 commit 373888b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/Exceptionless/Configuration/ExceptionlessConfiguration.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
namespace Exceptionless {
1515
public class ExceptionlessConfiguration {
1616
private const string DEFAULT_SERVER_URL = "https://collector.exceptionless.io";
17+
private const string DEFAULT_CONFIG_SERVER_URL = "https://config.exceptionless.io";
1718
private const string DEFAULT_HEARTBEAT_SERVER_URL = "https://heartbeat.exceptionless.io";
1819
private const string DEFAULT_USER_AGENT = "exceptionless/" + ThisAssembly.AssemblyFileVersion;
1920
private const int DEFAULT_SUBMISSION_BATCH_SIZE = 50;
2021

2122
private readonly IDependencyResolver _resolver;
2223
private bool _configLocked;
2324
private string _apiKey;
25+
private string _configServerUrl;
2426
private string _heartbeatServerUrl;
2527
private string _serverUrl;
2628
private bool _includePrivateInformation;
@@ -36,6 +38,7 @@ public ExceptionlessConfiguration(IDependencyResolver resolver) {
3638
throw new ArgumentNullException("resolver");
3739

3840
ServerUrl = DEFAULT_SERVER_URL;
41+
ConfigServerUrl = DEFAULT_CONFIG_SERVER_URL;
3942
HeartbeatServerUrl = DEFAULT_HEARTBEAT_SERVER_URL;
4043
UserAgent = DEFAULT_USER_AGENT;
4144
SubmissionBatchSize = DEFAULT_SUBMISSION_BATCH_SIZE;
@@ -78,11 +81,30 @@ public string ServerUrl {
7881

7982
_validationResult = null;
8083
_serverUrl = value;
84+
_configServerUrl = value;
8185
_heartbeatServerUrl = value;
8286
OnChanged();
8387
}
8488
}
8589

90+
/// <summary>
91+
/// The server url that all configuration will be retrieved from.
92+
/// </summary>
93+
public string ConfigServerUrl {
94+
get { return _configServerUrl; }
95+
set {
96+
if (_configServerUrl == value)
97+
return;
98+
99+
if (_configLocked)
100+
throw new ArgumentException("ConfigServerUrl can't be changed after the client has been initialized.");
101+
102+
_validationResult = null;
103+
_configServerUrl = value;
104+
OnChanged();
105+
}
106+
}
107+
86108
/// <summary>
87109
/// The server url that all events will be sent to.
88110
/// </summary>
@@ -514,6 +536,9 @@ public ValidationResult Validate() {
514536
if (String.IsNullOrEmpty(ServerUrl))
515537
result.Messages.Add("ServerUrl is not set.");
516538

539+
if (String.IsNullOrEmpty(ConfigServerUrl))
540+
result.Messages.Add("ConfigServerUrl is not set.");
541+
517542
if (String.IsNullOrEmpty(HeartbeatServerUrl))
518543
result.Messages.Add("HeartbeatServerUrl is not set.");
519544

src/Exceptionless/Submission/DefaultSubmissionClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public SettingsResponse GetSettings(ExceptionlessConfiguration config, int versi
8181
if (!config.IsValid)
8282
return new SettingsResponse(false, message: "Invalid client configuration settings.");
8383

84-
string url = String.Format("{0}/projects/config?v={1}", GetServiceEndPoint(config), version);
84+
string url = String.Format("{0}/projects/config?v={1}", GetConfigServiceEndPoint(config), version);
8585

8686
HttpResponseMessage response;
8787
try {
@@ -195,6 +195,17 @@ private Uri GetServiceEndPoint(ExceptionlessConfiguration config) {
195195
return builder.Uri;
196196
}
197197

198+
private Uri GetConfigServiceEndPoint(ExceptionlessConfiguration config) {
199+
var builder = new UriBuilder(config.ConfigServerUrl);
200+
builder.Path += builder.Path.EndsWith("/") ? "api/v2" : "/api/v2";
201+
202+
// EnableSSL
203+
if (builder.Scheme == "https" && builder.Port == 80 && !builder.Host.Contains("local"))
204+
builder.Port = 443;
205+
206+
return builder.Uri;
207+
}
208+
198209
private Uri GetHeartbeatServiceEndPoint(ExceptionlessConfiguration config) {
199210
var builder = new UriBuilder(config.HeartbeatServerUrl);
200211
builder.Path += builder.Path.EndsWith("/") ? "api/v2" : "/api/v2";

0 commit comments

Comments
 (0)