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

feat: add pm caching #29

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions Masa.Contrib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Contrib.Isolation.UoW.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Contrib.Isolation.UoW.EF.Web.Tests", "test\Masa.Contrib.Isolation.UoW.EF.Web.Tests\Masa.Contrib.Isolation.UoW.EF.Web.Tests.csproj", "{F4B8D71B-DAE4-4948-A1DC-42B42DE31D4F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Contrib.BasicAbility.Pm", "src\BasicAbility\Masa.Contrib.BasicAbility.PM\Masa.Contrib.BasicAbility.Pm.csproj", "{118A91A6-6FBB-431A-B50D-076375AD6A63}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.BuildingBlocks.BasicAbility.Pm", "src\BuildingBlocks\MASA.BuildingBlocks\src\BasicAbility\Masa.BuildingBlocks.BasicAbility.PM\Masa.BuildingBlocks.BasicAbility.Pm.csproj", "{AB6FAB84-5218-48A8-8F94-03B02ECD098F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Contrib.BasicAbility.Pm.Tests", "test\Masa.Contrib.BasicAbility.Pm.Tests\Masa.Contrib.BasicAbility.Pm.Tests.csproj", "{C4DDEA6E-D6AF-4890-9713-C2862403E57C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -604,6 +610,70 @@ Global
{F4B8D71B-DAE4-4948-A1DC-42B42DE31D4F}.Release|Any CPU.Build.0 = Release|Any CPU
{F4B8D71B-DAE4-4948-A1DC-42B42DE31D4F}.Release|x64.ActiveCfg = Release|Any CPU
{F4B8D71B-DAE4-4948-A1DC-42B42DE31D4F}.Release|x64.Build.0 = Release|Any CPU
{0C25062D-60A5-4690-974A-CDA9619866B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C25062D-60A5-4690-974A-CDA9619866B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C25062D-60A5-4690-974A-CDA9619866B4}.Debug|x64.ActiveCfg = Debug|Any CPU
{0C25062D-60A5-4690-974A-CDA9619866B4}.Debug|x64.Build.0 = Debug|Any CPU
{0C25062D-60A5-4690-974A-CDA9619866B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C25062D-60A5-4690-974A-CDA9619866B4}.Release|Any CPU.Build.0 = Release|Any CPU
{0C25062D-60A5-4690-974A-CDA9619866B4}.Release|x64.ActiveCfg = Release|Any CPU
{0C25062D-60A5-4690-974A-CDA9619866B4}.Release|x64.Build.0 = Release|Any CPU
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341}.Debug|x64.ActiveCfg = Debug|Any CPU
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341}.Debug|x64.Build.0 = Debug|Any CPU
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341}.Release|Any CPU.Build.0 = Release|Any CPU
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341}.Release|x64.ActiveCfg = Release|Any CPU
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341}.Release|x64.Build.0 = Release|Any CPU
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63}.Debug|x64.ActiveCfg = Debug|Any CPU
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63}.Debug|x64.Build.0 = Debug|Any CPU
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63}.Release|Any CPU.Build.0 = Release|Any CPU
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63}.Release|x64.ActiveCfg = Release|Any CPU
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63}.Release|x64.Build.0 = Release|Any CPU
{50551732-AAE0-4F77-B401-9DD02E226CDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50551732-AAE0-4F77-B401-9DD02E226CDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50551732-AAE0-4F77-B401-9DD02E226CDB}.Debug|x64.ActiveCfg = Debug|Any CPU
{50551732-AAE0-4F77-B401-9DD02E226CDB}.Debug|x64.Build.0 = Debug|Any CPU
{50551732-AAE0-4F77-B401-9DD02E226CDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50551732-AAE0-4F77-B401-9DD02E226CDB}.Release|Any CPU.Build.0 = Release|Any CPU
{50551732-AAE0-4F77-B401-9DD02E226CDB}.Release|x64.ActiveCfg = Release|Any CPU
{50551732-AAE0-4F77-B401-9DD02E226CDB}.Release|x64.Build.0 = Release|Any CPU
{7CF33D08-9468-464D-B52E-955A5667EE42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CF33D08-9468-464D-B52E-955A5667EE42}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CF33D08-9468-464D-B52E-955A5667EE42}.Debug|x64.ActiveCfg = Debug|Any CPU
{7CF33D08-9468-464D-B52E-955A5667EE42}.Debug|x64.Build.0 = Debug|Any CPU
{7CF33D08-9468-464D-B52E-955A5667EE42}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CF33D08-9468-464D-B52E-955A5667EE42}.Release|Any CPU.Build.0 = Release|Any CPU
{7CF33D08-9468-464D-B52E-955A5667EE42}.Release|x64.ActiveCfg = Release|Any CPU
{7CF33D08-9468-464D-B52E-955A5667EE42}.Release|x64.Build.0 = Release|Any CPU
{118A91A6-6FBB-431A-B50D-076375AD6A63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{118A91A6-6FBB-431A-B50D-076375AD6A63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{118A91A6-6FBB-431A-B50D-076375AD6A63}.Debug|x64.ActiveCfg = Debug|Any CPU
{118A91A6-6FBB-431A-B50D-076375AD6A63}.Debug|x64.Build.0 = Debug|Any CPU
{118A91A6-6FBB-431A-B50D-076375AD6A63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{118A91A6-6FBB-431A-B50D-076375AD6A63}.Release|Any CPU.Build.0 = Release|Any CPU
{118A91A6-6FBB-431A-B50D-076375AD6A63}.Release|x64.ActiveCfg = Release|Any CPU
{118A91A6-6FBB-431A-B50D-076375AD6A63}.Release|x64.Build.0 = Release|Any CPU
{AB6FAB84-5218-48A8-8F94-03B02ECD098F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB6FAB84-5218-48A8-8F94-03B02ECD098F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB6FAB84-5218-48A8-8F94-03B02ECD098F}.Debug|x64.ActiveCfg = Debug|Any CPU
{AB6FAB84-5218-48A8-8F94-03B02ECD098F}.Debug|x64.Build.0 = Debug|Any CPU
{AB6FAB84-5218-48A8-8F94-03B02ECD098F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB6FAB84-5218-48A8-8F94-03B02ECD098F}.Release|Any CPU.Build.0 = Release|Any CPU
{AB6FAB84-5218-48A8-8F94-03B02ECD098F}.Release|x64.ActiveCfg = Release|Any CPU
{AB6FAB84-5218-48A8-8F94-03B02ECD098F}.Release|x64.Build.0 = Release|Any CPU
{C4DDEA6E-D6AF-4890-9713-C2862403E57C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4DDEA6E-D6AF-4890-9713-C2862403E57C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4DDEA6E-D6AF-4890-9713-C2862403E57C}.Debug|x64.ActiveCfg = Debug|Any CPU
{C4DDEA6E-D6AF-4890-9713-C2862403E57C}.Debug|x64.Build.0 = Debug|Any CPU
{C4DDEA6E-D6AF-4890-9713-C2862403E57C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4DDEA6E-D6AF-4890-9713-C2862403E57C}.Release|Any CPU.Build.0 = Release|Any CPU
{C4DDEA6E-D6AF-4890-9713-C2862403E57C}.Release|x64.ActiveCfg = Release|Any CPU
{C4DDEA6E-D6AF-4890-9713-C2862403E57C}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -681,6 +751,14 @@ Global
{F1826D84-1A16-41A4-A57B-F0DBB5A18745} = {38E6C400-90C0-493E-9266-C1602E229F1B}
{2E1EEC9C-37C9-4C03-A4BC-58306F8B1C38} = {38E6C400-90C0-493E-9266-C1602E229F1B}
{F4B8D71B-DAE4-4948-A1DC-42B42DE31D4F} = {38E6C400-90C0-493E-9266-C1602E229F1B}
{0C25062D-60A5-4690-974A-CDA9619866B4} = {022D6FF5-4B65-4213-9A97-C69E2B2F99E1}
{6D9A3F62-8AB6-40AD-B32F-2A435A9D3341} = {022D6FF5-4B65-4213-9A97-C69E2B2F99E1}
{E9A3C62C-EA85-40C3-BB3B-7836D0337F63} = {022D6FF5-4B65-4213-9A97-C69E2B2F99E1}
{50551732-AAE0-4F77-B401-9DD02E226CDB} = {38E6C400-90C0-493E-9266-C1602E229F1B}
{7CF33D08-9468-464D-B52E-955A5667EE42} = {38E6C400-90C0-493E-9266-C1602E229F1B}
{118A91A6-6FBB-431A-B50D-076375AD6A63} = {5DFAF4A2-ECB5-46E4-904D-1EA5F48B2D48}
{AB6FAB84-5218-48A8-8F94-03B02ECD098F} = {DC578D74-98F0-4F19-A230-CFA8DAEE0AF1}
{C4DDEA6E-D6AF-4890-9713-C2862403E57C} = {38E6C400-90C0-493E-9266-C1602E229F1B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {40383055-CC50-4600-AD9A-53C14F620D03}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Masa.Contrib.BasicAbility.Pm.Service;

public class EnvironmentService : IEnvironmentService
{
private readonly ICallerProvider _callerProvider;

public EnvironmentService(ICallerProvider callerProvider)
{
_callerProvider = callerProvider;
}
}
6 changes: 6 additions & 0 deletions src/BasicAbility/Masa.Contrib.BasicAbility.Pm/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Masa.Contrib.BasicAbility.Pm;

public class Constants
{
internal const string DEFAULT_CLIENT_NAME = "masa.contrib.basicability.pm";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Masa.Utils.Caching.DistributedMemory" Version="0.4.0-preview.2" />
<PackageReference Include="Masa.Utils.Caching.Redis" Version="0.4.0-preview.2" />
<PackageReference Include="Masa.Utils.Caller.HttpClient" Version="0.4.0-preview.2" />
<PackageReference Include="Masa.Utils.Configuration.Json" Version="0.4.0-preview.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\BuildingBlocks\MASA.BuildingBlocks\src\BasicAbility\Masa.BuildingBlocks.BasicAbility.Pm\Masa.BuildingBlocks.BasicAbility.Pm.csproj" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions src/BasicAbility/Masa.Contrib.BasicAbility.Pm/PmClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Masa.Contrib.BasicAbility.Pm;

public class PmClient : IPmClient
{
public PmClient(ICallerProvider callerProvider)
{
EnvironmentService = new EnvironmentService(callerProvider);
ClusterService = new ClusterService(callerProvider);
ProjectService = new ProjectService(callerProvider);
AppService = new AppService(callerProvider);
}

public IProjectService ProjectService { get; init; }

public IEnvironmentService EnvironmentService { get; init; }

public IClusterService ClusterService { get; init; }

public IAppService AppService { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Masa.Contrib.BasicAbility.Pm.Service;

public class AppService : IAppService
{
private readonly ICallerProvider _callerProvider;

public AppService(ICallerProvider callerProvider)
{
_callerProvider = callerProvider;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Masa.Contrib.BasicAbility.Pm.Service;

public class ClusterService : IClusterService
{
private readonly ICallerProvider _callerProvider;

public ClusterService(ICallerProvider callerProvider)
{
_callerProvider = callerProvider;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Masa.Contrib.BasicAbility.Pm.Service;

public class EnvironmentService : IEnvironmentService
{
private readonly ICallerProvider _callerProvider;

public EnvironmentService(ICallerProvider callerProvider)
{
_callerProvider = callerProvider;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

namespace Masa.Contrib.BasicAbility.Pm.Service
{
public class ProjectService : IProjectService
{
private readonly ICallerProvider _callerProvider;

public ProjectService(ICallerProvider callerProvider)
{
_callerProvider = callerProvider;
}

public async Task<List<ProjectModel>> GetProjectListAsync(string envName)
{
var requestUri = $"api/v1/project-with-apps/{envName}";
var result = await _callerProvider.GetAsync<List<ProjectModel>>(requestUri);

return result ?? new List<ProjectModel>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Masa.Contrib.BasicAbility.Pm;

public static class ServiceCollectionExtensions
{
public static IServiceCollection AddPmClient(this IServiceCollection services, Action<CallerOptions> callerOptions)
{
if (services.Any(service => service.ServiceType.Equals(typeof(IPmClient))))
return services;

services.AddCaller(options =>
{
callerOptions.Invoke(options);
});

services.AddSingleton<IPmClient>(serviceProvider =>
{
var callProvider = serviceProvider.GetRequiredService<ICallerFactory>().CreateClient(DEFAULT_CLIENT_NAME);
var pmCaching = new PmClient(callProvider);
return pmCaching;
});

return services;
}
}
7 changes: 7 additions & 0 deletions src/BasicAbility/Masa.Contrib.BasicAbility.Pm/_Imports.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
global using Masa.BuildingBlocks.BasicAbility.Pm;
global using Masa.BuildingBlocks.BasicAbility.Pm.Model;
global using Microsoft.Extensions.DependencyInjection;
global using Masa.Utils.Caller.Core;
global using static Masa.Contrib.BasicAbility.Pm.Constants;
global using Masa.Contrib.BasicAbility.Pm.Service;
global using Masa.BuildingBlocks.BasicAbility.Pm.Service;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\BasicAbility\Masa.Contrib.BasicAbility.PM\Masa.Contrib.BasicAbility.Pm.csproj" />
</ItemGroup>

</Project>
Loading