-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/emberstack/ES.FX into de…
…velop
- Loading branch information
Showing
56 changed files
with
1,126 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/ES.FX.Ignite.Azure.Common/ES.FX.Ignite.Azure.Common.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Identity" Version="1.12.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.4" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ES.FX.Ignite.Spark\ES.FX.Ignite.Spark.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
82 changes: 82 additions & 0 deletions
82
src/ES.FX.Ignite.Azure.Common/Hosting/AzureCommonHostingExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using Azure.Core.Extensions; | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.Azure; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
|
||
namespace ES.FX.Ignite.Azure.Common.Hosting; | ||
|
||
[PublicAPI] | ||
public static class AzureCommonHostingExtensions | ||
{ | ||
/// <summary> | ||
/// Registers an Azure Client with the specified settings and options | ||
/// </summary> | ||
/// <param name="services">The <see cref="IServiceCollection" /> to read config from and add services to.</param> | ||
/// <param name="serviceKey"> | ||
/// If not null, registers a keyed service with the service key. If null, registers a default | ||
/// service | ||
/// </param> | ||
/// <param name="configuration">Configuration for the client.</param> | ||
/// <param name="configureOptions"> | ||
/// An optional delegate that can be used for customizing options. It's invoked after the | ||
/// options are read from the configuration. | ||
/// </param> | ||
public static void IgniteAzureClient<TClient, TOptions>(this IServiceCollection services, | ||
string? serviceKey, | ||
IConfigurationSection configuration, | ||
Action<TOptions>? configureOptions = null) | ||
where TOptions : class | ||
where TClient : class | ||
{ | ||
services.AddAzureClients(azureClientFactoryBuilder => | ||
{ | ||
var clientBuilder = | ||
((IAzureClientFactoryBuilderWithConfiguration<IConfigurationSection>)azureClientFactoryBuilder) | ||
.RegisterClientFactory<TClient, TOptions>(configuration); | ||
|
||
if (!string.IsNullOrWhiteSpace(serviceKey)) clientBuilder.WithName(serviceKey); | ||
clientBuilder.ConfigureOptions(options => configureOptions?.Invoke(options)); | ||
}); | ||
|
||
|
||
if (!string.IsNullOrWhiteSpace(serviceKey)) | ||
services.AddKeyedSingleton(serviceKey, | ||
static (serviceProvider, serviceKey) => serviceProvider | ||
.GetRequiredService<IAzureClientFactory<TClient>>().CreateClient((string)serviceKey!)); | ||
} | ||
|
||
/// <summary> | ||
/// Registers the observability for the Azure Client | ||
/// </summary> | ||
/// <param name="services">The <see cref="IServiceCollection" /> to read config from and add services to.</param> | ||
/// <param name="serviceKey"> | ||
/// If not null, registers a keyed service with the service key. If null, registers a default | ||
/// service | ||
/// </param> | ||
/// <param name="tracingEnabled"> Indicates if Tracing is enabled or not. </param> | ||
/// <param name="healthChecksEnabled"> Indicates if HealthChecks are enabled or not. </param> | ||
/// <param name="healthCheckFactory"> The factory used to create the health checks if enabled</param> | ||
public static void IgniteAzureClientObservability<TClient>(this IServiceCollection services, string? serviceKey, | ||
bool tracingEnabled, | ||
bool healthChecksEnabled, | ||
Func<IServiceProvider, TClient, IHealthCheck> healthCheckFactory) where TClient : class | ||
{ | ||
if (tracingEnabled) | ||
services.AddOpenTelemetry().WithTracing(traceBuilder => | ||
traceBuilder.AddSource([$"{typeof(TClient).Namespace}.*"])); | ||
|
||
if (healthChecksEnabled) | ||
{ | ||
var healthCheckName = | ||
$"{nameof(Azure)}-{typeof(TClient).Name}-{(string.IsNullOrWhiteSpace(serviceKey) ? string.Empty : $"[{serviceKey}]")}"; | ||
services.AddHealthChecks().Add(new HealthCheckRegistration(healthCheckName, | ||
serviceProvider => healthCheckFactory(serviceProvider, | ||
serviceProvider.GetRequiredKeyedService<TClient>(serviceKey)), | ||
default, | ||
[nameof(Azure), typeof(TClient).Name], | ||
default)); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/ES.FX.Ignite.Azure.Data.Tables/AzureDataTablesSpark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using ES.FX.Ignite.Spark.Configuration; | ||
|
||
namespace ES.FX.Ignite.Azure.Data.Tables; | ||
|
||
/// <summary> | ||
/// <see cref="AzureDataTablesSpark" /> definition | ||
/// </summary> | ||
public static class AzureDataTablesSpark | ||
{ | ||
/// <summary> | ||
/// Spark name | ||
/// </summary> | ||
public const string Name = "AzureDataTables"; | ||
|
||
/// <summary> | ||
/// The default configuration section path | ||
/// </summary> | ||
public const string ConfigurationSectionPath = | ||
$"{IgniteConfigurationSections.Ignite}:{nameof(Azure)}:{nameof(Data)}:{nameof(Tables)}"; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/ES.FX.Ignite.Azure.Data.Tables/Configuration/AzureDataTablesSparkSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Azure.Data.Tables; | ||
using ES.FX.Ignite.Spark.Configuration.Abstractions; | ||
|
||
namespace ES.FX.Ignite.Azure.Data.Tables.Configuration; | ||
|
||
/// <summary> | ||
/// Provides the settings for connecting to Azure Storage using a <see cref="TableServiceClient" /> | ||
/// </summary> | ||
public class AzureDataTablesSparkSettings : ISparkHealthCheckSettings, ISparkTracingSettings | ||
{ | ||
/// <summary> | ||
/// <inheritdoc cref="ISparkHealthCheckSettings.HealthChecksEnabled" /> | ||
/// </summary> | ||
public bool HealthChecksEnabled { get; set; } = true; | ||
|
||
/// <summary> | ||
/// <inheritdoc cref="ISparkTracingSettings.TracingEnabled" /> | ||
/// </summary> | ||
public bool TracingEnabled { get; set; } = true; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/ES.FX.Ignite.Azure.Data.Tables/ES.FX.Ignite.Azure.Data.Tables.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup> | ||
|
||
<PackageReference Include="AspNetCore.HealthChecks.Azure.Data.Tables" Version="8.0.1" /> | ||
<PackageReference Include="Azure.Data.Tables" Version="12.9.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ES.FX.Ignite.Azure.Common\ES.FX.Ignite.Azure.Common.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.