diff --git a/samples/apis/Backet.Api/Backet.Api.csproj b/samples/apis/Backet.Api/Backet.Api.csproj
index ae744f7..4e5d3f8 100644
--- a/samples/apis/Backet.Api/Backet.Api.csproj
+++ b/samples/apis/Backet.Api/Backet.Api.csproj
@@ -16,11 +16,11 @@
-
+
-
+
diff --git a/samples/apis/Backet.Api/EventHandlers/ToNoticeBacketCreatedEventHandler.cs b/samples/apis/Backet.Api/EventHandlers/ToNoticeBacketCreatedEventHandler.cs
index db48cce..dbfd1e4 100644
--- a/samples/apis/Backet.Api/EventHandlers/ToNoticeBacketCreatedEventHandler.cs
+++ b/samples/apis/Backet.Api/EventHandlers/ToNoticeBacketCreatedEventHandler.cs
@@ -11,7 +11,7 @@ namespace Backet.Api.EventHandlers
public class ToNoticeBacketCreatedEventHandler : PoleEventHandler, IToNoticeBacketCreatedEventHandler
{
public async Task BulkEventsHandle(List @event)
- {
+ {
await Task.Delay(1500);
}
diff --git a/samples/apis/Backet.Api/GrpcServices/BacketService.cs b/samples/apis/Backet.Api/GrpcServices/BacketService.cs
index ca4ecac..6fd2ec9 100644
--- a/samples/apis/Backet.Api/GrpcServices/BacketService.cs
+++ b/samples/apis/Backet.Api/GrpcServices/BacketService.cs
@@ -19,7 +19,7 @@ namespace Backet.Api.GrpcServices
public override async Task AddBacket(AddBacketRequest backetDto, ServerCallContext context)
{
var newId = Guid.NewGuid().ToString("N").ToLower();
- backetDto.Id = newId;
+ //backetDto.Id = newId;
var grain = clusterClient.GetGrain(newId);
//await grain.AddBacket(backetDto);
return Pole.Grpc.ExtraType.CommonCommandResponse.SuccessResponse;
diff --git a/samples/apis/Backet.Api/Program.cs b/samples/apis/Backet.Api/Program.cs
index 05226d0..8f4c69e 100644
--- a/samples/apis/Backet.Api/Program.cs
+++ b/samples/apis/Backet.Api/Program.cs
@@ -25,14 +25,14 @@ namespace Backet.Api
Host.CreateDefaultBuilder(args)
.UseOrleans(siloBuilder =>
{
- siloBuilder.ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory());
- siloBuilder.UseLocalhostClustering();
- siloBuilder.AddEfGrainStorage("ef");
- siloBuilder.Configure(options =>
- {
- options.CollectionAge = TimeSpan.FromMinutes(2);
- });
- siloBuilder.UseDashboard(options => { });
+ siloBuilder.ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory())
+ .UseLocalhostClustering()
+ .AddEfGrainStorage("ef")
+ .Configure(options =>
+ {
+ options.CollectionAge = TimeSpan.FromSeconds(65);
+ })
+ .UseDashboard(options => { });
})
.ConfigureWebHostDefaults(webBuilder =>
{
@@ -46,6 +46,7 @@ namespace Backet.Api
option.ListenAnyIP(82, config =>
{
config.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
+ config.UseHttps();
});
});
});
diff --git a/samples/apis/Backet.Api/Protos/backet.proto b/samples/apis/Backet.Api/Protos/backet.proto
index 6b32a22..57918db 100644
--- a/samples/apis/Backet.Api/Protos/backet.proto
+++ b/samples/apis/Backet.Api/Protos/backet.proto
@@ -2,7 +2,7 @@ syntax = "proto3";
option csharp_namespace = "Backet.Grpc";
-import "Protos/Common/commonCommandResponse.proto";
+import "Common/commonCommandResponse.proto";
package greet;
// The greeting service definition.
@@ -14,13 +14,13 @@ service Backet {
// The request message containing the user's name.
message AddBacketRequest {
string name = 1;
- string id = 2;
- string userId = 3;
- repeated AddBacketItemRequest Items = 4;
- message AddBacketItemRequest{
- string productId = 1;
- string productName = 2;
- int64 price = 3;
- }
+ //string id = 2;
+ //string userId = 3;
+ //repeated AddBacketItemRequest Items = 4;
+ //message AddBacketItemRequest{
+ // string productId = 1;
+ // string productName = 2;
+ // int64 price = 3;
+ //}
}
diff --git a/samples/apis/Backet.Api/Startup.cs b/samples/apis/Backet.Api/Startup.cs
index 97b596e..21f0358 100644
--- a/samples/apis/Backet.Api/Startup.cs
+++ b/samples/apis/Backet.Api/Startup.cs
@@ -32,7 +32,13 @@ namespace Backet.Api
services.AddGrpcValidation();
services.AddGrpcRequestValidator();
services.AddGrpcWeb(o => o.GrpcWebEnabled = true);
-
+ services.AddCors(o => o.AddPolicy("AllowAll", builder =>
+ {
+ builder.AllowAnyOrigin()
+ .AllowAnyMethod()
+ .AllowAnyHeader()
+ .WithExposedHeaders("Grpc-Status", "Grpc-Message");
+ }));
services.AddPole(config =>
{
config.AddRabbitMQ(option =>
@@ -66,11 +72,12 @@ namespace Backet.Api
app.UseRouting();
app.UseGrpcWeb();
+ app.UseCors("AllowAll");
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
- endpoints.MapGrpcService();
+ endpoints.MapGrpcService().EnableGrpcWeb();
});
}
}
diff --git a/samples/apis/Backet.Api/appsettings.json b/samples/apis/Backet.Api/appsettings.json
index 5dbb82b..7f7d987 100644
--- a/samples/apis/Backet.Api/appsettings.json
+++ b/samples/apis/Backet.Api/appsettings.json
@@ -4,7 +4,8 @@
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
- "Grpc": "Information"
+ "Grpc": "Information",
+ "Microsoft.AspNetCore.Server.Kestrel": "Debug"
}
},
"postgres": {