✨ Add grpc reflection
This commit is contained in:
@@ -21,6 +21,7 @@ public static class ApplicationConfiguration
|
||||
app.MapControllers();
|
||||
|
||||
app.MapGrpcService<CustomAppServiceGrpc>();
|
||||
app.MapGrpcReflectionService();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public static class ServiceCollectionExtensions
|
||||
});
|
||||
|
||||
services.AddGrpc(options => { options.EnableDetailedErrors = true; });
|
||||
services.AddGrpcReflection();
|
||||
|
||||
services.Configure<RequestLocalizationOptions>(options =>
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ public static class ApplicationBuilderExtensions
|
||||
// Map your gRPC services here
|
||||
app.MapGrpcService<FileServiceGrpc>();
|
||||
app.MapGrpcService<FileReferenceServiceGrpc>();
|
||||
app.MapGrpcReflectionService();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public static class ServiceCollectionExtensions
|
||||
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
});
|
||||
|
||||
// Register gRPC reflection for service discovery
|
||||
services.AddGrpc();
|
||||
services.AddGrpcReflection();
|
||||
|
||||
services.AddControllers().AddJsonOptions(options =>
|
||||
{
|
||||
|
||||
@@ -26,9 +26,7 @@ public static class ServiceCollectionExtensions
|
||||
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
});
|
||||
|
||||
// Register gRPC reflection for service discovery
|
||||
services.AddGrpc();
|
||||
services.AddGrpcReflection();
|
||||
|
||||
// Register gRPC services
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public static class ApplicationConfiguration
|
||||
app.MapGrpcService<WalletServiceGrpc>();
|
||||
app.MapGrpcService<PaymentServiceGrpc>();
|
||||
app.MapGrpcService<RealmServiceGrpc>();
|
||||
app.MapGrpcReflectionService();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public static class ServiceCollectionExtensions
|
||||
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
});
|
||||
services.AddGrpcReflection();
|
||||
|
||||
services.AddRingService();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ public static class ApplicationConfiguration
|
||||
public static WebApplication ConfigureGrpcServices(this WebApplication app)
|
||||
{
|
||||
app.MapGrpcService<RingServiceGrpc>();
|
||||
app.MapGrpcReflectionService();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,7 @@ public static class ServiceCollectionExtensions
|
||||
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
});
|
||||
|
||||
// Register gRPC reflection for service discovery
|
||||
services.AddGrpc();
|
||||
services.AddGrpcReflection();
|
||||
|
||||
// Register gRPC services
|
||||
services.AddScoped<RingServiceGrpc>();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<PackageReference Include="Google.Protobuf.Tools" Version="3.33.0" />
|
||||
<PackageReference Include="Grpc" Version="2.46.6" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Server.ClientFactory" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Server.Reflection" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.72.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
@@ -130,33 +130,28 @@ public class PostServiceGrpc(AppDatabase db, PostService ps) : Shared.Proto.Post
|
||||
.Include(p => p.FeaturedRecords)
|
||||
.Where(p => p.DeletedAt == null)
|
||||
.AsQueryable();
|
||||
|
||||
query = request.Shuffle
|
||||
? query.OrderBy(e => EF.Functions.Random())
|
||||
: query.OrderByDescending(e => e.PublishedAt ?? e.CreatedAt);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.PublisherId) && Guid.TryParse(request.PublisherId, out var pid))
|
||||
{
|
||||
query = query.Where(p => p.PublisherId == pid);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.RealmId) && Guid.TryParse(request.RealmId, out var rid))
|
||||
{
|
||||
query = query.Where(p => p.RealmId == rid);
|
||||
}
|
||||
|
||||
if (request.Categories.Count > 0)
|
||||
{
|
||||
query = query.Where(p => p.Categories.Any(c => request.Categories.Contains(c.Slug)));
|
||||
}
|
||||
|
||||
if (request.Tags.Count > 0)
|
||||
{
|
||||
query = query.Where(p => p.Tags.Any(c => request.Tags.Contains(c.Slug)));
|
||||
}
|
||||
|
||||
// TODO: Add types filtering when proto is regenerated
|
||||
// if (request.Types.Count > 0)
|
||||
// {
|
||||
// var types = request.Types.Select(t => (Shared.Models.PostType)t).Distinct();
|
||||
// query = query.Where(p => types.Contains(p.Type));
|
||||
// }
|
||||
if (request.Types_.Count > 0)
|
||||
{
|
||||
var types = request.Types_.Select(t => (Shared.Models.PostType)t).Distinct();
|
||||
query = query.Where(p => types.Contains(p.Type));
|
||||
}
|
||||
|
||||
if (request.OnlyMedia)
|
||||
{
|
||||
@@ -175,11 +170,7 @@ public class PostServiceGrpc(AppDatabase db, PostService ps) : Shared.Proto.Post
|
||||
};
|
||||
|
||||
// Include/exclude replies
|
||||
if (request.IncludeReplies)
|
||||
{
|
||||
// Include both root and reply posts
|
||||
}
|
||||
else
|
||||
if (!request.IncludeReplies)
|
||||
{
|
||||
// Exclude reply posts, only root posts
|
||||
query = query.Where(e => e.RepliedPostId == null);
|
||||
@@ -214,12 +205,7 @@ public class PostServiceGrpc(AppDatabase db, PostService ps) : Shared.Proto.Post
|
||||
var pageToken = request.PageToken;
|
||||
var offset = string.IsNullOrEmpty(pageToken) ? 0 : int.Parse(pageToken);
|
||||
|
||||
// Ordering - TODO: Add shuffle when proto field is available
|
||||
var orderedQuery = request.Shuffle
|
||||
? query.OrderBy(e => EF.Functions.Random())
|
||||
: query.OrderByDescending(e => e.PublishedAt ?? e.CreatedAt);
|
||||
|
||||
var posts = await orderedQuery
|
||||
var posts = await query
|
||||
.Skip(offset)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
|
||||
@@ -23,6 +23,7 @@ public static class ApplicationConfiguration
|
||||
// Map gRPC services
|
||||
app.MapGrpcService<PostServiceGrpc>();
|
||||
app.MapGrpcService<PublisherServiceGrpc>();
|
||||
app.MapGrpcReflectionService();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public static class ServiceCollectionExtensions
|
||||
services.AddRazorPages();
|
||||
|
||||
services.AddGrpc(options => { options.EnableDetailedErrors = true; });
|
||||
services.AddGrpcReflection();
|
||||
|
||||
services.Configure<RequestLocalizationOptions>(options =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user