added two samples

This commit is contained in:
2026-02-03 08:31:53 -05:00
parent 97e0ce1733
commit 51f577d218
1120 changed files with 45859 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WolverineFx.Nats" Version="5.13.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Messages\Messages.csproj" />
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,57 @@
using Messages;
using Wolverine;
using Wolverine.Nats;
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
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);
});
options.ListenToNatsSubject("messages-sent")
.BufferedInMemory();
// While this will sort of work, you should have exactly one handler for request-response
// semantics - wolverine will take it, but log an error.
// options.ListenToNatsSubject("math.add")
// .ProcessInline();
options.ListenToNatsSubject("people.>")
.UseJetStream("PEOPLE", "late-comer");
});
var app = builder.Build();
app.MapDefaultEndpoints();
app.Run();
public static class MessageHandler
{
public static void Handle(SendMessage message, ILogger logger)
{
logger.LogInformation($"Received message: {message.Message}");
}
public static void Handle(UserDocument user, ILogger logger)
{
logger.LogInformation($"Received user: {user.Id} - {user.Name}");
}
public static void Handle(UserNameChanged change, ILogger logger)
{
logger.LogInformation($"User name changed: {change.Id} - {change.NewName}");
}
public static NumbersAdded Handle(AddThem request)
{
return new NumbersAdded(42);
}
}

View File

@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://latecomer.dev.localhost:5282",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://latecomer.dev.localhost:9210;http://latecomer.dev.localhost:5282",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Npgsql": "Warning",
"Wolverine": "Warning"
}
},
"AllowedHosts": "*"
}

File diff suppressed because it is too large Load Diff

View File

@@ -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
}
}
}

View File

@@ -0,0 +1 @@
{"Version":1,"ManifestType":"Build","Endpoints":[]}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Npgsql": "Warning",
"Wolverine": "Warning"
}
},
"AllowedHosts": "*"
}

Some files were not shown because too many files have changed in this diff Show More