added two samples
This commit is contained in:
20
wolverine-nats/WolverineAndNats/ApiTwo/ApiTwo.csproj
Normal file
20
wolverine-nats/WolverineAndNats/ApiTwo/ApiTwo.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Messages\Messages.csproj" />
|
||||
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Npgsql" Version="13.1.0" />
|
||||
<PackageReference Include="WolverineFx.Marten" Version="5.13.0" />
|
||||
<PackageReference Include="WolverineFx.Nats" Version="5.13.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
81
wolverine-nats/WolverineAndNats/ApiTwo/Program.cs
Normal file
81
wolverine-nats/WolverineAndNats/ApiTwo/Program.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using Marten;
|
||||
using Messages;
|
||||
using Wolverine;
|
||||
using Wolverine.Marten;
|
||||
using Wolverine.Nats;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.AddServiceDefaults();
|
||||
builder.AddNpgsqlDataSource("db-two");
|
||||
|
||||
builder.UseWolverine(options =>
|
||||
{
|
||||
options.UseNats(builder.Configuration.GetConnectionString("nats") ??
|
||||
throw new Exception("No NATS connection string configured"))
|
||||
.AutoProvision()
|
||||
.UseJetStream(js =>
|
||||
{
|
||||
js.MaxDeliver = 5;
|
||||
js.AckWait = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
//.DefineWorkQueueStream("APITWO", s => s.EnableScheduledDelivery(), "users.>");
|
||||
|
||||
options.ListenToNatsSubject("messages-sent")
|
||||
.BufferedInMemory();
|
||||
|
||||
options.ListenToNatsSubject("math.add")
|
||||
.ProcessInline();
|
||||
|
||||
options.ListenToNatsSubject("people.>")
|
||||
.UseJetStream("PEOPLE", "api-two");
|
||||
|
||||
|
||||
});
|
||||
|
||||
builder.Services.AddMarten(config =>
|
||||
{
|
||||
|
||||
}).UseLightweightSessions()
|
||||
.IntegrateWithWolverine()
|
||||
.UseNpgsqlDataSource();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapGet("/users", async (IDocumentSession session) =>
|
||||
{
|
||||
var response = await session.Query<UserDocument>().ToListAsync();
|
||||
return Results.Ok(response);
|
||||
});
|
||||
|
||||
app.Run();
|
||||
|
||||
public static class MessageHandler
|
||||
{
|
||||
public static void Handle(SendMessage message, ILogger logger)
|
||||
{
|
||||
logger.LogInformation($"Received message: {message.Message}");
|
||||
}
|
||||
|
||||
public static NumbersAdded Handle(AddThem request)
|
||||
{
|
||||
var sum = request.Numbers.Sum();
|
||||
return new NumbersAdded(sum);
|
||||
}
|
||||
public static async Task Handle(UserDocument user, IDocumentSession session)
|
||||
{
|
||||
session.Store(user);
|
||||
await session.SaveChangesAsync();
|
||||
}
|
||||
public static async Task Handle(UserNameChanged nameChanged, IDocumentSession session)
|
||||
{
|
||||
var user = await session.LoadAsync<UserDocument>(nameChanged.Id);
|
||||
if (user != null)
|
||||
{
|
||||
var updatedUser = user with { Name = nameChanged.NewName };
|
||||
session.Store(updatedUser);
|
||||
await session.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://apitwo.dev.localhost:7204",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
11
wolverine-nats/WolverineAndNats/ApiTwo/appsettings.json
Normal file
11
wolverine-nats/WolverineAndNats/ApiTwo/appsettings.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Npgsql": "Warning",
|
||||
"Wolverine": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/ApiTwo
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/ApiTwo
Executable file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net10.0",
|
||||
"frameworks": [
|
||||
{
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "10.0.0"
|
||||
},
|
||||
{
|
||||
"name": "Microsoft.AspNetCore.App",
|
||||
"version": "10.0.0"
|
||||
}
|
||||
],
|
||||
"configProperties": {
|
||||
"System.GC.Server": true,
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"Version":1,"ManifestType":"Build","Endpoints":[]}
|
||||
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Aspire.Npgsql.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Aspire.Npgsql.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/FSharp.Core.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/FSharp.Core.dll
Executable file
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/HealthChecks.NpgSql.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/HealthChecks.NpgSql.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Humanizer.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Humanizer.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/JasperFx.Events.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/JasperFx.Events.dll
Executable file
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/JasperFx.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/JasperFx.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Marten.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Marten.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NATS.Client.Core.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NATS.Client.Core.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NATS.Client.Hosting.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NATS.Client.Hosting.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NATS.Net.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NATS.Net.dll
Executable file
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NetTopologySuite.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NetTopologySuite.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NewId.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/NewId.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Newtonsoft.Json.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Newtonsoft.Json.dll
Executable file
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Npgsql.Json.NET.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Npgsql.Json.NET.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Npgsql.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Npgsql.dll
Executable file
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/OpenTelemetry.Api.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/OpenTelemetry.Api.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/OpenTelemetry.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/OpenTelemetry.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Polly.Core.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Polly.Core.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Polly.Extensions.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Polly.Extensions.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Polly.RateLimiting.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Polly.RateLimiting.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Spectre.Console.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Spectre.Console.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Weasel.Core.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Weasel.Core.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Weasel.Postgresql.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Weasel.Postgresql.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Wolverine.Marten.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Wolverine.Marten.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Wolverine.Nats.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Wolverine.Nats.dll
Executable file
Binary file not shown.
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Wolverine.RDBMS.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Wolverine.RDBMS.dll
Executable file
Binary file not shown.
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Wolverine.dll
Executable file
BIN
wolverine-nats/WolverineAndNats/ApiTwo/bin/Debug/net10.0/Wolverine.dll
Executable file
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Npgsql": "Warning",
|
||||
"Wolverine": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user