Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper methods to AzureClient and AzureSilo for easier programmatic config #1622

Merged
merged 1 commit into from
Mar 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/OrleansAzureUtils/Hosting/AzureClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading;
using Orleans.Runtime.Configuration;

Expand Down Expand Up @@ -74,6 +75,22 @@ public static void Uninitialize()
GrainClient.Uninitialize();
}

/// <summary>
/// Returns default client configuration object for passing to AzureClient.
/// </summary>
/// <returns></returns>
public static ClientConfiguration DefaultConfiguration()
{
var config = new ClientConfiguration
{
GatewayProvider = ClientConfiguration.GatewayProviderType.AzureTable,
DeploymentId = GetDeploymentId(),
DataConnectionString = GetDataConnectionString(),
};

return config;
}

#region Internal implementation of client initialization processing

private static void InitializeImpl_FromFile(FileInfo configFile)
Expand Down Expand Up @@ -123,12 +140,12 @@ private static void InitializeImpl_FromFile(FileInfo configFile)
InitializeImpl_FromConfig(config);
}

private static string GetDeploymentId()
internal static string GetDeploymentId()
{
return GrainClient.TestOnlyNoConnect ? "FakeDeploymentId" : serviceRuntimeWrapper.DeploymentId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, would there be a need to use "FakeDeploymentId" elsewhere? E.g. in some comparison operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I don't even see it being used in tests. Probably a leftover from the past. But this PR isn't concerned with it.

}

private static string GetDataConnectionString()
internal static string GetDataConnectionString()
{
return GrainClient.TestOnlyNoConnect
? "FakeConnectionString"
Expand Down
11 changes: 11 additions & 0 deletions src/OrleansAzureUtils/Hosting/AzureSilo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ public AzureSilo()
logger = TraceLogger.GetLogger("OrleansAzureSilo", TraceLogger.LoggerType.Runtime);
}

public static ClusterConfiguration DefaultConfiguration()
{
var config = new ClusterConfiguration();

config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.AzureTable;
config.Globals.DeploymentId = AzureClient.GetDeploymentId();
config.Globals.DataConnectionString = AzureClient.GetDataConnectionString();

return config;
}

#region Azure RoleEntryPoint methods

/// <summary>
Expand Down