Skip to content

Commit

Permalink
Merge pull request #7 from NerosoftDev/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Codespilot authored Jul 7, 2023
2 parents 055da74 + 5eea8f3 commit d0b1ff3
Show file tree
Hide file tree
Showing 139 changed files with 6,378 additions and 285 deletions.
13 changes: 7 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Autofac.Extras.DynamicProxy" Version="7.1.0" />
<PackageVersion Include="AutoMapper" Version="12.0.1" />
<PackageVersion Include="Azure.Storage.Blobs" Version="12.16.0" />
<PackageVersion Include="Castle.Core" Version="5.1.1" />
<PackageVersion Include="Consul" Version="1.6.10.9" />
<PackageVersion Include="FluentValidation" Version="11.5.2" />
<PackageVersion Include="FluentValidation" Version="11.6.0" />
<PackageVersion Include="IdentityModel" Version="6.1.0" />
<PackageVersion Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="6.2.0" />
<PackageVersion Include="Mapster" Version="7.3.0" />
Expand Down Expand Up @@ -52,6 +53,7 @@
<PackageVersion Include="System.Runtime.Loader" Version="4.3.0" />
<PackageVersion Include="System.Text.Json" Version="7.0.3" />
<PackageVersion Include="Winton.Extensions.Configuration.Consul" Version="3.2.0" />
<PackageVersion Include="ZooKeeperNetEx" Version="3.4.12.4" />
</ItemGroup>
<!-- Microsoft.Extensions -->
<ItemGroup>
Expand Down Expand Up @@ -95,17 +97,16 @@
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.8" />

</ItemGroup>
<!-- Grpc -->
<ItemGroup>
<PackageVersion Include="Google.Protobuf" Version="3.23.3" />
<PackageVersion Include="Grpc" Version="2.46.6" />
<PackageVersion Include="Grpc.AspNetCore" Version="2.54.0" />
<PackageVersion Include="Grpc.AspNetCore.Server" Version="2.54.0" />
<PackageVersion Include="Grpc.AspNetCore.Server.Reflection" Version="2.54.0" />
<PackageVersion Include="Grpc.AspNetCore" Version="2.55.0" />
<PackageVersion Include="Grpc.AspNetCore.Server" Version="2.55.0" />
<PackageVersion Include="Grpc.AspNetCore.Server.Reflection" Version="2.55.0" />
<PackageVersion Include="Grpc.Core" Version="2.46.6" />
<PackageVersion Include="Grpc.HealthCheck" Version="2.54.0" />
<PackageVersion Include="Grpc.HealthCheck" Version="2.55.0" />
<PackageVersion Include="Grpc.Tools" Version="2.54.0" />
</ItemGroup>
<!-- Tests -->
Expand Down
49 changes: 47 additions & 2 deletions Euonia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Caching", "Caching", "{2673
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Euonia.Caching.Tests.Shared", "Tests\Euonia.Caching.Tests.Shared\Euonia.Caching.Tests.Shared.shproj", "{4A28CD6B-0C75-4D39-B613-66DE6B693675}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Euonia.Caching.Runtime.Tests", "Tests\Euonia.Caching.Runtime.Tests\Euonia.Caching.Runtime.Tests.csproj", "{EFA1CD9D-4B53-483C-BF9D-F21B9B2C6FDE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Caching.Runtime.Tests", "Tests\Euonia.Caching.Runtime.Tests\Euonia.Caching.Runtime.Tests.csproj", "{EFA1CD9D-4B53-483C-BF9D-F21B9B2C6FDE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Euonia.Caching.Default.Tests", "Tests\Euonia.Caching.Default.Tests\Euonia.Caching.Default.Tests.csproj", "{ACACF41C-B5CB-4C9F-B378-3F15ED15F1D1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Caching.Default.Tests", "Tests\Euonia.Caching.Default.Tests\Euonia.Caching.Default.Tests.csproj", "{ACACF41C-B5CB-4C9F-B378-3F15ED15F1D1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Threading", "Source\Euonia.Threading\Euonia.Threading.csproj", "{D71E9924-333D-4417-8FB6-BAB1533C420A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Threading.Redis", "Source\Euonia.Threading.Redis\Euonia.Threading.Redis.csproj", "{5FF78A05-D3B8-4E4E-891C-C4F14E9D2BCD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Threading.Azure", "Source\Euonia.Threading.Azure\Euonia.Threading.Azure.csproj", "{667DC49A-C0A9-46B3-9C0B-6BE2E9EFD4D2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Threading.FileSystem", "Source\Euonia.Threading.FileSystem\Euonia.Threading.FileSystem.csproj", "{AC00CE1D-A54D-4243-9762-49A33CF4548B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Euonia.Threading.ZooKeeper", "Source\Euonia.Threading.ZooKeeper\Euonia.Threading.ZooKeeper.csproj", "{0DADDE7F-28D9-43B3-8CC5-88BBE887CBD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -271,6 +281,36 @@ Global
{ACACF41C-B5CB-4C9F-B378-3F15ED15F1D1}.Product|Any CPU.Build.0 = Debug|Any CPU
{ACACF41C-B5CB-4C9F-B378-3F15ED15F1D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ACACF41C-B5CB-4C9F-B378-3F15ED15F1D1}.Release|Any CPU.Build.0 = Release|Any CPU
{D71E9924-333D-4417-8FB6-BAB1533C420A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D71E9924-333D-4417-8FB6-BAB1533C420A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D71E9924-333D-4417-8FB6-BAB1533C420A}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{D71E9924-333D-4417-8FB6-BAB1533C420A}.Product|Any CPU.Build.0 = Debug|Any CPU
{D71E9924-333D-4417-8FB6-BAB1533C420A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D71E9924-333D-4417-8FB6-BAB1533C420A}.Release|Any CPU.Build.0 = Release|Any CPU
{5FF78A05-D3B8-4E4E-891C-C4F14E9D2BCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5FF78A05-D3B8-4E4E-891C-C4F14E9D2BCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FF78A05-D3B8-4E4E-891C-C4F14E9D2BCD}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{5FF78A05-D3B8-4E4E-891C-C4F14E9D2BCD}.Product|Any CPU.Build.0 = Debug|Any CPU
{5FF78A05-D3B8-4E4E-891C-C4F14E9D2BCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FF78A05-D3B8-4E4E-891C-C4F14E9D2BCD}.Release|Any CPU.Build.0 = Release|Any CPU
{667DC49A-C0A9-46B3-9C0B-6BE2E9EFD4D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{667DC49A-C0A9-46B3-9C0B-6BE2E9EFD4D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{667DC49A-C0A9-46B3-9C0B-6BE2E9EFD4D2}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{667DC49A-C0A9-46B3-9C0B-6BE2E9EFD4D2}.Product|Any CPU.Build.0 = Debug|Any CPU
{667DC49A-C0A9-46B3-9C0B-6BE2E9EFD4D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{667DC49A-C0A9-46B3-9C0B-6BE2E9EFD4D2}.Release|Any CPU.Build.0 = Release|Any CPU
{AC00CE1D-A54D-4243-9762-49A33CF4548B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC00CE1D-A54D-4243-9762-49A33CF4548B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC00CE1D-A54D-4243-9762-49A33CF4548B}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{AC00CE1D-A54D-4243-9762-49A33CF4548B}.Product|Any CPU.Build.0 = Debug|Any CPU
{AC00CE1D-A54D-4243-9762-49A33CF4548B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC00CE1D-A54D-4243-9762-49A33CF4548B}.Release|Any CPU.Build.0 = Release|Any CPU
{0DADDE7F-28D9-43B3-8CC5-88BBE887CBD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DADDE7F-28D9-43B3-8CC5-88BBE887CBD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DADDE7F-28D9-43B3-8CC5-88BBE887CBD9}.Product|Any CPU.ActiveCfg = Debug|Any CPU
{0DADDE7F-28D9-43B3-8CC5-88BBE887CBD9}.Product|Any CPU.Build.0 = Debug|Any CPU
{0DADDE7F-28D9-43B3-8CC5-88BBE887CBD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DADDE7F-28D9-43B3-8CC5-88BBE887CBD9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -314,6 +354,11 @@ Global
{4A28CD6B-0C75-4D39-B613-66DE6B693675} = {2673555B-2E7C-417B-8D1A-25F3FE05A141}
{EFA1CD9D-4B53-483C-BF9D-F21B9B2C6FDE} = {2673555B-2E7C-417B-8D1A-25F3FE05A141}
{ACACF41C-B5CB-4C9F-B378-3F15ED15F1D1} = {2673555B-2E7C-417B-8D1A-25F3FE05A141}
{D71E9924-333D-4417-8FB6-BAB1533C420A} = {5EEB0F25-5A4E-4A68-975C-53E42A959621}
{5FF78A05-D3B8-4E4E-891C-C4F14E9D2BCD} = {5EEB0F25-5A4E-4A68-975C-53E42A959621}
{667DC49A-C0A9-46B3-9C0B-6BE2E9EFD4D2} = {5EEB0F25-5A4E-4A68-975C-53E42A959621}
{AC00CE1D-A54D-4243-9762-49A33CF4548B} = {5EEB0F25-5A4E-4A68-975C-53E42A959621}
{0DADDE7F-28D9-43B3-8CC5-88BBE887CBD9} = {5EEB0F25-5A4E-4A68-975C-53E42A959621}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {84CDDCF4-F3D0-45FC-87C5-557845F58F55}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Castle.DynamicProxy;
using Nerosoft.Euonia.Core;
using Nerosoft.Euonia.Validation;

namespace Nerosoft.Euonia.Application;
Expand Down
2 changes: 1 addition & 1 deletion Source/Euonia.Bus.RabbitMq/CommandConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private async void HandleMessageReceived(object _, BasicDeliverEventArgs args)
var props = args.BasicProperties;
var replyNeeded = !string.IsNullOrEmpty(props.CorrelationId);

var message = CommandConsumer<TCommand>.Deserialize(body.ToArray());
var message = Deserialize(body.ToArray());
OnMessageReceived(new MessageReceivedEventArgs(message, messageContext));

var taskCompletion = new TaskCompletionSource<object>();
Expand Down
2 changes: 1 addition & 1 deletion Source/Euonia.Bus.RabbitMq/RabbitMqMessageBusOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RabbitMqMessageBusOptions
/// Gets or sets the exchange type.
/// Values: fanout, direct, headers, topic
/// </summary>
public string ExchangeType { get; set; } = global::RabbitMQ.Client.ExchangeType.Fanout;
public string ExchangeType { get; set; } = RabbitMQ.Client.ExchangeType.Fanout;

/// <summary>
///
Expand Down
4 changes: 2 additions & 2 deletions Source/Euonia.Caching.Redis/RedisCacheBackplane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Nerosoft.Euonia.Caching.Redis;
public sealed class RedisCacheBackplane : CacheBackplane
{
private const int HARD_LIMIT = 50000;
private readonly string _channelName;
private readonly RedisChannel _channelName;
private readonly byte[] _identifier;
private readonly RedisConnectionManager _connection;
private readonly Timer _timer;
Expand All @@ -40,7 +40,7 @@ public RedisCacheBackplane(CacheManagerConfiguration configuration, string conne
: base(configuration)
{
Check.EnsureNotNull(configuration, nameof(configuration));
_channelName = configuration.BackplaneChannelName ?? "CacheManagerBackplane";
_channelName = new RedisChannel(configuration.BackplaneChannelName ?? "CacheManagerBackplane", RedisChannel.PatternMode.Auto);
_identifier = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString());

var cfg = RedisConfigurations.GetConfiguration(ConfigurationKey, connectionString);
Expand Down
16 changes: 8 additions & 8 deletions Source/Euonia.Caching.Redis/RedisCacheHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ private CacheItem<TValue> GetCacheItemAndVersion(string key, string region, out
return cacheItem;
}

protected CacheItem<TValue> GetCacheItemInternalNoScript(string key, string region)
protected virtual CacheItem<TValue> GetCacheItemInternalNoScript(string key, string region)
{
return Retry(() =>
{
Expand Down Expand Up @@ -619,7 +619,7 @@ protected override bool RemoveInternal(string key, string region)
private void SubscribeKeyspaceNotifications()
{
_connection.Subscriber.Subscribe(
$"__keyevent@{_redisConfiguration.Database}__:expired",
new RedisChannel($"__keyevent@{_redisConfiguration.Database}__:expired", RedisChannel.PatternMode.Auto),
(_, key) =>
{
var tuple = ParseKey(key);
Expand All @@ -628,7 +628,7 @@ private void SubscribeKeyspaceNotifications()
});

_connection.Subscriber.Subscribe(
$"__keyevent@{_redisConfiguration.Database}__:evicted",
new RedisChannel($"__keyevent@{_redisConfiguration.Database}__:evicted", RedisChannel.PatternMode.Auto),
(_, key) =>
{
var tuple = ParseKey(key);
Expand All @@ -638,7 +638,7 @@ private void SubscribeKeyspaceNotifications()
});

_connection.Subscriber.Subscribe(
$"__keyevent@{_redisConfiguration.Database}__:del",
new RedisChannel($"__keyevent@{_redisConfiguration.Database}__:del", RedisChannel.PatternMode.Auto),
(_, key) =>
{
var tuple = ParseKey(key);
Expand Down Expand Up @@ -745,14 +745,14 @@ private RedisValue ToRedisValue(TValue value)
return _valueConverter.ToRedisValue(value);
}

private T Retry<T>(Func<T> retryme) =>
RetryHelper.Retry(retryme, _managerConfiguration.RetryTimeout, _managerConfiguration.MaxRetries);
private T Retry<T>(Func<T> action) =>
RetryHelper.Retry(action, _managerConfiguration.RetryTimeout, _managerConfiguration.MaxRetries);

private void Retry(Action retryme)
private void Retry(Action action)
=> Retry(
() =>
{
retryme();
action();
return true;
});

Expand Down
4 changes: 2 additions & 2 deletions Source/Euonia.Caching.Redis/RedisCacheService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ public TValue AddOrUpdate<TValue>(string key, TValue value, DateTime timeout, bo
/// <inheritdoc />
public TValue AddOrUpdate<TValue>(CacheItem<TValue> item)
{
var key = RewriteKey(item.Key);

return _manager.Instance<TValue>().AddOrUpdate(item, _ => item.Value);
}

Expand All @@ -109,6 +107,7 @@ public async Task<TValue> GetOrAddAsync<TValue>(string key, Func<Task<TValue>> f
{
return value;
}

value = await factory();
var result = _manager.Instance<TValue>().GetOrAdd(key, _ => GetCacheItem(key, value, timeout));
return result.Value;
Expand Down Expand Up @@ -169,6 +168,7 @@ private static CacheItem<TValue> GetCacheItem<TValue>(string key, TValue value,
{
item = new CacheItem<TValue>(key, value);
}

return item;
}
}
59 changes: 59 additions & 0 deletions Source/Euonia.Core/Collections/EquatableReadOnlyList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
namespace Nerosoft.Euonia.Collections;

/// <summary>
/// Represents a read-only list that enabled comparison of two instance of the <see cref="EquatableReadOnlyList{T}"/> for equality.
/// </summary>
/// <typeparam name="T">The element type.</typeparam>
public readonly struct EquatableReadOnlyList<T> : IReadOnlyList<T>, IEquatable<EquatableReadOnlyList<T>>
{
private readonly T[] _array;

/// <summary>
/// Initializes a new instance of the <see cref="EquatableReadOnlyList{T}"/> class.
/// </summary>
/// <param name="items"></param>
public EquatableReadOnlyList(IEnumerable<T> items)
{
_array = items.ToArray();
}

/// <inheritdoc />
public T this[int index] => _array[index];

/// <summary>
/// Gets the element count of the list.
/// </summary>
public int Count => _array.Length;

/// <inheritdoc />
public bool Equals(EquatableReadOnlyList<T> other) => _array.SequenceEqual(other._array);

/// <inheritdoc />
public override bool Equals(object obj) => obj is EquatableReadOnlyList<T> that && Equals(that);

/// <inheritdoc />
public override int GetHashCode()
{
return _array.Aggregate(0, (current, item) => (current, item).GetHashCode());
}

/// <summary>
/// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns></returns>
public IEnumerator<T> GetEnumerator() => _array.As<IEnumerable<T>>().GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

/// <inheritdoc />
public static bool operator ==(EquatableReadOnlyList<T> left, EquatableReadOnlyList<T> right)
{
return left.Equals(right);
}

/// <inheritdoc />
public static bool operator !=(EquatableReadOnlyList<T> left, EquatableReadOnlyList<T> right)
{
return !(left == right);
}
}
4 changes: 4 additions & 0 deletions Source/Euonia.Core/Collections/TreeView.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
namespace Nerosoft.Euonia.Collections;

/// <summary>
/// A tree structural object.
/// </summary>
/// <typeparam name="TEntity"></typeparam>
public class TreeView<TEntity>
{
/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions Source/Euonia.Core/Collections/ViewCollection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
namespace Nerosoft.Euonia.Collections;

/// <summary>
/// To be added.
/// </summary>
/// <typeparam name="T"></typeparam>
public class ViewCollection<T>
where T : class, new()
{
Expand Down
18 changes: 17 additions & 1 deletion Source/Euonia.Core/Dependency/IServiceAccessor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
namespace System;

/// <summary>
/// Accessing services from the IoC container.
/// </summary>
public interface IServiceAccessor : ISingletonDependency
{
/// <summary>
/// Gets or sets the service provider.
/// </summary>
IServiceProvider ServiceProvider { get; set; }


/// <summary>
/// Resolves an instance of the requested type from the <see cref="ServiceProvider"/>.
/// </summary>
/// <typeparam name="T">The service type.</typeparam>
/// <returns></returns>
T GetService<T>();

/// <summary>
/// Resolves an instance of the requested type from the <see cref="ServiceProvider"/>.
/// </summary>
/// <param name="type">The service type.</param>
/// <returns></returns>
object GetService(Type type);
}
6 changes: 6 additions & 0 deletions Source/Euonia.Core/Dependency/ServiceAccessor.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
namespace System;

/// <summary>
/// Implements the <see cref="IServiceAccessor"/> interface to provides a way to access services.
/// </summary>
public class ServiceAccessor : IServiceAccessor
{
private static readonly AsyncLocal<IServiceProvider> _provider = new();

/// <inheritdoc/>
public IServiceProvider ServiceProvider
{
get => _provider.Value;
set => _provider.Value = value;
}

/// <inheritdoc/>
public T GetService<T>()
{
return (T)GetService(typeof(T));
}

/// <inheritdoc/>
public object GetService(Type type)
{
return _provider.Value?.GetService(type);
Expand Down
2 changes: 1 addition & 1 deletion Source/Euonia.Core/Exceptions/BusinessException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.Serialization;

namespace Nerosoft.Euonia;
namespace Nerosoft.Euonia.Core;

/// <summary>
/// Represents errors that occur during business logic execution.
Expand Down
5 changes: 4 additions & 1 deletion Source/Euonia.Core/Exceptions/ConfigurationException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.Runtime.Serialization;

namespace Nerosoft.Euonia;
namespace Nerosoft.Euonia.Core;

/// <summary>
/// Represents errors that occur during application configuration.
/// </summary>
[Serializable]
public class ConfigurationException : Exception
{
Expand Down
Loading

0 comments on commit d0b1ff3

Please sign in to comment.