Skip to content

Commit

Permalink
feat: support for webassembly
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinyouzeng committed Jan 18, 2025
1 parent 3be7fd0 commit c790bbb
Show file tree
Hide file tree
Showing 86 changed files with 567 additions and 250 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<TargetFramework>net8.0</TargetFramework>
<DotnetVersion>8.0</DotnetVersion>
<MasaFrameworkPackageVersion>1.2.0-preview.5</MasaFrameworkPackageVersion>
<MasaSdkPackageVersion>1.2.1-preview.14</MasaSdkPackageVersion>
<MasaSdkPackageVersion>1.2.1-preview.15</MasaSdkPackageVersion>
</PropertyGroup>
</Project>
44 changes: 44 additions & 0 deletions Masa.Tsc.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Tsc.Repository", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Tsc.Domain.Shared", "src\Infrastructure\Masa.Tsc.Domain.Shared\Masa.Tsc.Domain.Shared.csproj", "{16AD3AC4-E4CD-410E-AD2B-13EC0D1FE982}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Tsc.Storage.Elasticsearch.Shared", "src\Infrastructure\Masa.Tsc.Storage.Elasticsearch.Shared\Masa.Tsc.Storage.Elasticsearch.Shared.csproj", "{ECAF575F-9AEA-43EA-85B0-6A17139FF355}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Tsc.Storage.Clickhouse.Apm.Shared", "src\Infrastructure\Masa.Tsc.Storage.Clickhouse.Apm.Shared\Masa.Tsc.Storage.Clickhouse.Apm.Shared.csproj", "{89BC571F-908D-4C91-B3F5-18E559E83470}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Tsc.Storage.Prometheus.Shared", "src\Infrastructure\Masa.Tsc.Storage.Prometheus.Shared\Masa.Tsc.Storage.Prometheus.Shared.csproj", "{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Tsc.Storage.Clickhouse.Shared", "src\Infrastructure\Masa.Tsc.Storage.Clickhouse.Shared\Masa.Tsc.Storage.Clickhouse.Shared.csproj", "{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -216,6 +224,38 @@ Global
{16AD3AC4-E4CD-410E-AD2B-13EC0D1FE982}.Release|Any CPU.Build.0 = Release|Any CPU
{16AD3AC4-E4CD-410E-AD2B-13EC0D1FE982}.Release|x86.ActiveCfg = Release|Any CPU
{16AD3AC4-E4CD-410E-AD2B-13EC0D1FE982}.Release|x86.Build.0 = Release|Any CPU
{ECAF575F-9AEA-43EA-85B0-6A17139FF355}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECAF575F-9AEA-43EA-85B0-6A17139FF355}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECAF575F-9AEA-43EA-85B0-6A17139FF355}.Debug|x86.ActiveCfg = Debug|Any CPU
{ECAF575F-9AEA-43EA-85B0-6A17139FF355}.Debug|x86.Build.0 = Debug|Any CPU
{ECAF575F-9AEA-43EA-85B0-6A17139FF355}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECAF575F-9AEA-43EA-85B0-6A17139FF355}.Release|Any CPU.Build.0 = Release|Any CPU
{ECAF575F-9AEA-43EA-85B0-6A17139FF355}.Release|x86.ActiveCfg = Release|Any CPU
{ECAF575F-9AEA-43EA-85B0-6A17139FF355}.Release|x86.Build.0 = Release|Any CPU
{89BC571F-908D-4C91-B3F5-18E559E83470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89BC571F-908D-4C91-B3F5-18E559E83470}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89BC571F-908D-4C91-B3F5-18E559E83470}.Debug|x86.ActiveCfg = Debug|Any CPU
{89BC571F-908D-4C91-B3F5-18E559E83470}.Debug|x86.Build.0 = Debug|Any CPU
{89BC571F-908D-4C91-B3F5-18E559E83470}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89BC571F-908D-4C91-B3F5-18E559E83470}.Release|Any CPU.Build.0 = Release|Any CPU
{89BC571F-908D-4C91-B3F5-18E559E83470}.Release|x86.ActiveCfg = Release|Any CPU
{89BC571F-908D-4C91-B3F5-18E559E83470}.Release|x86.Build.0 = Release|Any CPU
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}.Debug|x86.ActiveCfg = Debug|Any CPU
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}.Debug|x86.Build.0 = Debug|Any CPU
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}.Release|Any CPU.Build.0 = Release|Any CPU
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}.Release|x86.ActiveCfg = Release|Any CPU
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E}.Release|x86.Build.0 = Release|Any CPU
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}.Debug|x86.ActiveCfg = Debug|Any CPU
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}.Debug|x86.Build.0 = Debug|Any CPU
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}.Release|Any CPU.Build.0 = Release|Any CPU
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}.Release|x86.ActiveCfg = Release|Any CPU
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -244,6 +284,10 @@ Global
{CD04814A-A4B1-4D3E-8D66-3FFF7D2D5A21} = {386CA149-7280-4F1F-A064-4F3B9643C082}
{86E453B5-7F2D-4E00-9FF5-523715FBEA1E} = {386CA149-7280-4F1F-A064-4F3B9643C082}
{16AD3AC4-E4CD-410E-AD2B-13EC0D1FE982} = {386CA149-7280-4F1F-A064-4F3B9643C082}
{ECAF575F-9AEA-43EA-85B0-6A17139FF355} = {386CA149-7280-4F1F-A064-4F3B9643C082}
{89BC571F-908D-4C91-B3F5-18E559E83470} = {386CA149-7280-4F1F-A064-4F3B9643C082}
{978E03D2-4335-4F94-A8DE-450FD9CB6A4E} = {386CA149-7280-4F1F-A064-4F3B9643C082}
{DDBBABB5-AAC0-4FBE-8630-8BBD403987A2} = {386CA149-7280-4F1F-A064-4F3B9643C082}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B83BA2BA-19E5-41FB-A92A-16A03DA229E4}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ internal static class ICallerExtensions
public static async Task<TResult> GetByBodyAsync<TResult>(this ICaller caller, string url, object body, CancellationToken? token = null) where TResult : class
{

if (caller is DaprCaller daprCaller)
{
var request = daprCaller.CreateRequest(HttpMethod.Get, url, body);
return (await daprCaller.SendAsync<TResult>(request, token ?? default)) ?? default!;
}
else
//if (caller is DaprCaller daprCaller)
//{
// var request = daprCaller.CreateRequest(HttpMethod.Get, url, body);
// return (await daprCaller.SendAsync<TResult>(request, token ?? default)) ?? default!;
//}
//else
{
var request = new HttpRequestMessage(HttpMethod.Get, url);
if (body != null)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

namespace Microsoft.Extensions.DependencyInjection;

public static class TscCallerServiceExtensions
{
internal const string DEFAULT_CLIENT_NAME = "masa.tsc.apigateways.caller";
internal const string AUTH_CLIENT_NAME = "masa.tsc.auth.apigateways.caller";

//public static IServiceCollection AddTscApiCaller(this IServiceCollection services, string appid, string authAppid)
//{
// try
// {
// var caller = services.BuildServiceProvider().GetRequiredService<ICallerFactory>().Create(DEFAULT_CLIENT_NAME);
// if (caller != null)
// return services;
// }
// catch
// {
// IServiceProvider serviceProviderCopy = services.BuildServiceProvider();
// services.AddCaller(DEFAULT_CLIENT_NAME, builder =>
// {
// builder.UseDapr(options => options.AppId = appid,
// builder => builder.UseDaprApiToken(serviceProviderCopy.GetRequiredService<TokenProvider>()?.AccessToken));
// }).AddCaller(AUTH_CLIENT_NAME, builder =>
// {
// builder.UseDapr(options => options.AppId = authAppid,
// builder => builder.UseDaprApiToken(serviceProviderCopy.GetRequiredService<TokenProvider>()?.AccessToken));
// });

// services.AddScoped(serviceProvider =>
// {
// serviceProviderCopy = serviceProvider;
// var callerFactory = serviceProvider.GetRequiredService<ICallerFactory>();
// var client = new TscCaller(serviceProviderCopy, callerFactory);
// return client;
// });
// }

// return services;
//}

public static IServiceCollection AddTscHttpApiCaller(this IServiceCollection services, string tscApiUrl, string authApiUrl)
{
try
{
var caller = services.BuildServiceProvider().GetRequiredService<ICallerFactory>().Create(DEFAULT_CLIENT_NAME);
if (caller != null)
return services;
}
catch
{
services.AddCaller(DEFAULT_CLIENT_NAME, builder =>
{
builder.UseHttpClient(options => options.BaseAddress = tscApiUrl).UseAuthentication();
})
.AddCaller(AUTH_CLIENT_NAME, builder =>
{
builder.UseHttpClient(options => options.BaseAddress = authApiUrl).UseAuthentication();
});

services.AddScoped(serviceProvider =>
{
var callerFactory = serviceProvider.GetRequiredService<ICallerFactory>();
var client = new TscCaller(serviceProvider, callerFactory);
return client;
});
}

return services;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Masa.Contrib.StackSdks.Dcc" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.Service.Caller.DaprClient" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.BuildingBlocks.Data.Contracts" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.BuildingBlocks.StackSdks.Tsc.Contracts" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Dcc.Wasm" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Pm.Wasm" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Auth.Wasm" Version="$(MasaSdkPackageVersion)" />
<!--<PackageReference Include="Masa.Contrib.Service.Caller.DaprClient" Version="$(MasaFrameworkPackageVersion)" />-->
<!--<PackageReference Include="Masa.BuildingBlocks.Data.Contracts" Version="$(MasaFrameworkPackageVersion)" />-->
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(DotnetVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Contracts\Masa.Tsc.Contracts.Admin\Masa.Tsc.Contracts.Admin.csproj" />
<ProjectReference Include="..\..\Infrastructure\Masa.Tsc.Storage.Clickhouse.Apm\Masa.Tsc.Storage.Clickhouse.Apm.csproj" />
<ProjectReference Include="..\..\Infrastructure\Masa.Tsc.Storage.Elasticsearch\Masa.Tsc.Storage.Elasticsearch.csproj" />
<ProjectReference Include="..\..\Infrastructure\Masa.Tsc.Storage.Clickhouse.Apm.Shared\Masa.Tsc.Storage.Clickhouse.Apm.Shared.csproj" />
<ProjectReference Include="..\..\Infrastructure\Masa.Tsc.Storage.Elasticsearch.Shared\Masa.Tsc.Storage.Elasticsearch.Shared.csproj" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/ApiGateways/Masa.Tsc.ApiGateways.Caller/TscCaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class TscCaller
{
internal TscCaller(IServiceProvider serviceProvider, ICallerFactory callerFactory)
{
var caller = callerFactory.Create(ServiceExtensions.DEFAULT_CLIENT_NAME);
var caller = callerFactory.Create(TscCallerServiceExtensions.DEFAULT_CLIENT_NAME);
AppService = new AppService(caller);
SettingService = new SettingService(caller);
ProjectService = new ProjectService(caller, serviceProvider.GetRequiredService<IDccClient>());
Expand All @@ -20,7 +20,7 @@ internal TscCaller(IServiceProvider serviceProvider, ICallerFactory callerFactor
TopologyService = new TopologyService(caller);
ApmService = new ApmService(caller);
ExceptErrorService=new ExceptErrorService(caller);
UserService = new UserService(callerFactory.Create(ServiceExtensions.AUTH_CLIENT_NAME), serviceProvider.GetRequiredService<IAuthClient>());
UserService = new UserService(callerFactory.Create(TscCallerServiceExtensions.AUTH_CLIENT_NAME), serviceProvider.GetRequiredService<IAuthClient>());
}

public AppService AppService { get; private init; }
Expand Down
5 changes: 3 additions & 2 deletions src/ApiGateways/Masa.Tsc.ApiGateways.Caller/_Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
global using Masa.BuildingBlocks.StackSdks.Tsc.Contracts.Model.Aggregate;
global using Masa.BuildingBlocks.StackSdks.Tsc.Contracts.Trace;
global using Masa.Contrib.Service.Caller;
global using Masa.Contrib.Service.Caller.DaprClient;
global using Masa.Contrib.StackSdks.Caller;
//global using Masa.Contrib.Service.Caller.DaprClient;
//global using Masa.Contrib.StackSdks.Caller;
global using Masa.Tsc.ApiGateways.Caller.Services;
global using Masa.Tsc.Contracts.Admin;
global using Masa.Tsc.Contracts.Admin.Apps;
Expand All @@ -31,3 +31,4 @@
global using Microsoft.Extensions.DependencyInjection;
global using System.Text;
global using System.Text.Json;
global using Masa.Tsc.ApiGateways.Caller;
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Instruments\Query\**" />
<EmbeddedResource Remove="Instruments\Query\**" />
<None Remove="Instruments\Query\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.4.0" />
<PackageReference Include="Masa.BuildingBlocks.StackSdks.Tsc.Contracts" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.Authentication.Identity" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Auth" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Pm" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.Configuration.ConfigurationApi.Dcc" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<!--<PackageReference Include="Masa.BuildingBlocks.StackSdks.Tsc.Contracts" Version="$(MasaSdkPackageVersion)" />-->
<PackageReference Include="Masa.BuildingBlocks.StackSdks.Auth.Contracts" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.BuildingBlocks.StackSdks.Pm" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
<!--<PackageReference Include="Masa.Contrib.Authentication.Identity" Version="$(MasaFrameworkPackageVersion)" />-->
<!--<PackageReference Include="Masa.Contrib.StackSdks.Auth" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Pm" Version="$(MasaSdkPackageVersion)" />-->
<!--<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />-->
<PackageReference Include="Util.Reflection" Version="1.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Infrastructure\Masa.Tsc.Storage.Prometheus\Masa.Tsc.Storage.Prometheus.csproj" />
<ProjectReference Include="..\..\Infrastructure\Masa.Tsc.Storage.Prometheus.Shared\Masa.Tsc.Storage.Prometheus.Shared.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Contracts\Masa.Tsc.Contracts.Admin\Masa.Tsc.Contracts.Admin.csproj" />
</ItemGroup>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Contracts\Masa.Tsc.Contracts.Admin\Masa.Tsc.Contracts.Admin.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Masa.BuildingBlocks.Ddd.Domain" Version="$(MasaFrameworkPackageVersion)" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions src/Infrastructure/Masa.Tsc.Domain/Masa.Tsc.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="Masa.Contrib.Caching.MultilevelCache" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Config" Version="$(MasaStackSdksPackageVersion)" />
<!--<PackageReference Include="Masa.Contrib.StackSdks.Dcc.Wasm" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Pm.Wasm" Version="$(MasaSdkPackageVersion)" />-->
<PackageReference Include="Masa.Contrib.StackSdks.Auth" Version="$(MasaSdkPackageVersion)" />
<PackageReference Include="Masa.Contrib.Dispatcher.Events" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Middleware" Version="$(MasaSdkPackageVersion)" />
</ItemGroup>
Expand All @@ -18,6 +21,7 @@
<ProjectReference Include="..\Masa.Tsc.EFCore\Masa.Tsc.EFCore.csproj" />
<ProjectReference Include="..\Masa.Tsc.Repository\Masa.Tsc.Repository.csproj" />
<ProjectReference Include="..\Masa.Tsc.Storage.Clickhouse.Apm\Masa.Tsc.Storage.Clickhouse.Apm.csproj" />
<ProjectReference Include="..\Masa.Tsc.Storage.Prometheus\Masa.Tsc.Storage.Prometheus.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit c790bbb

Please sign in to comment.