Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wolverine 3.0 Punchlist things #1068

Merged
merged 4 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
492 changes: 239 additions & 253 deletions build/build.cs

Large diffs are not rendered by default.

17 changes: 5 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ services:


localstack:
image: localstack/localstack
image: localstack/localstack:stable
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
Expand All @@ -59,15 +59,8 @@ services:
- 22181:2181

kafka:
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
image: confluentinc/confluent-local:latest
ports:
- 29092:29092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
- "8082:8082"
- "9092:9092"
- "9101:9101"
38 changes: 37 additions & 1 deletion docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Wolverine 3.0 *is* tested with both the built in `ServiceProvider` and Lamar. It
IoC containers now as long as they conform to the .NET conforming container, but this isn't tested by the Wolverine team.
:::

Wolverine is configured with the `IHostBuilder.UseWolverine()` extension methods, with the actual configuration
Wolverine is configured with the `IHostBuilder.UseWolverine()` or `HostApplicationBuilder` extension methods, with the actual configuration
living on a single `WolverineOptions` object. The `WolverineOptions` is the configuration model for your Wolverine application,
and as such it can be used to configure directives about:

Expand All @@ -25,6 +25,42 @@ At this point, Wolverine only supports [IHostBuilder](https://learn.microsoft.co
model in the future.
:::

## Replacing ServiceProvider with Lamar

If you run into any trouble whatsoever with code generation after upgrading to Wolverine 3.0, please:

1. Please [raise a GitHub issue in Wolverine](https://github.com/JasperFx/wolverine/issues/new/choose) with some description of the offending message handler or http endpoint
2. Fall back to Lamar for your IoC tool

To use Lamar, add this Nuget to your main project:

```bash
dotnet add package Lamar.Microsoft.DependencyInjection
```

If you're using `IHostBuilder` like you might for a simple console app, it's:

snippet: sample_use_lamar_with_host_builder

In a web application, it's:

```csharp
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseLamar();
```

and with `HostApplicationBuilder`, try:

```csharp
var builder = Host.CreateApplicationBuilder();

// Little ugly, and Lamar *should* have a helper for this...
builder.ConfigureContainer<ServiceRegistry>(new LamarServiceProviderFactory());
```




## With ASP.NET Core

Below is a sample of adding Wolverine to an ASP.NET Core application that is bootstrapped with
Expand Down
1 change: 0 additions & 1 deletion docs/guide/messaging/transports/kafka.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Using Kafka


::: warning
The Kafka transport does not really support the "Requeue" error handling policy in Wolverine. "Requeue" in this case becomes
effectively an inline "Retry"
Expand Down
26 changes: 25 additions & 1 deletion docs/guide/messaging/transports/pulsar.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# Using Pulsar
# Using Pulsar <Badge type="tip" text="3.0" />

::: info
Fun fact, the Pulsar transport was actually the very first messaging broker to be supported
by Jasper/Wolverine, but for whatever reason, wasn't officially released until Wolverine 3.0.
:::

## Installing

To use [Apache Pulsar](https://pulsar.apache.org/) as a messaging transport with Wolverine, first install the `WolverineFx.Pulsar` library via nuget to your project. Behind the scenes, this package uses the [DotPulsar client library](https://pulsar.apache.org/docs/next/client-libraries-dotnet/) managed library for accessing Pulsar brokers.

```bash
dotnet add WolverineFx.Pulsar
```

To connect to Pulsar and configure senders and listeners, use this syntax:

snippet: sample_configuring_pulsar

The topic name format is set by Pulsar itself, and you can learn more about its format in [Pulsar Topics](https://pulsar.apache.org/docs/next/concepts-messaging/#topics).

::: info
Depending on demand, the Pulsar transport will be enhanced to support conventional routing topologies and more advanced
topic routing later.
:::
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/Testing/CoreTests/Configuration/DocumentationSamples.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Lamar;
using Lamar.Microsoft.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace CoreTests.Configuration;

public static class DocumentationSamples
{
public static async Task bootstrap_with_lamar()
{
#region sample_use_lamar_with_host_builder

// With IHostBuilder
var builder = Host.CreateDefaultBuilder();
builder.UseLamar();

#endregion


}

public static async Task bootstrap_with_lamar_using_web_app()
{
var builder = Host.CreateApplicationBuilder();

// Little ugly, and Lamar *should* have a helper for this...
builder.ConfigureContainer<ServiceRegistry>(new LamarServiceProviderFactory());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public BufferedComplianceFixture() : base(new Uri("sqs://receiver"), 120)

public async Task InitializeAsync()
{
var number = Guid.NewGuid().ToString();
var number = Guid.NewGuid().ToString().Replace(".", "-");

OutboundAddress = new Uri("sqs://receiver-" + number);

Expand All @@ -42,7 +42,6 @@ public async Task DisposeAsync()
}
}

[Collection("acceptance")]
public class BufferedSendingAndReceivingCompliance : TransportCompliance<BufferedComplianceFixture>
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task no_seriously_do_not_create_dlq()
.UseWolverine(options =>
{
options.PersistMessagesWithPostgresql(Servers.PostgresConnectionString);
options.UseAmazonSqsTransportLocally();
options.UseAmazonSqsTransportLocally().DisableAllNativeDeadLetterQueues().AutoProvision();

options.Durability.Mode = DurabilityMode.Solo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public async Task DisposeAsync()
await DisposeAsync();
}

[Collection("acceptance")]
public class DurableSendingAndReceivingCompliance : TransportCompliance<DurableComplianceFixture>
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public async Task DisposeAsync()
}
}

[Collection("acceptance")]
public class InlineSendingAndReceivingCompliance : TransportCompliance<InlineComplianceFixture>
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Xunit;

[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public async Task DisposeAsync()
}
}

[Collection("acceptance")]
public class PrefixedSendingAndReceivingCompliance : TransportCompliance<PrefixedComplianceFixture>
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected override AmazonSqsQueue findEndpointByUri(Uri uri)
{
throw new ArgumentOutOfRangeException(nameof(uri));
}
return Queues.Where(x => x.Uri.OriginalString == uri.OriginalString).FirstOrDefault() ?? Queues[uri.OriginalString.Split("//")[1]];
return Queues.Where(x => x.Uri.OriginalString == uri.OriginalString).FirstOrDefault() ?? Queues[uri.OriginalString.Split("//")[1].TrimEnd('/')];
}

public override ValueTask ConnectAsync(IWolverineRuntime runtime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public async Task DisposeAsync()
}
}

[Collection("acceptance")]
public class BufferedSendingAndReceivingCompliance : TransportCompliance<BufferedComplianceFixture>
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ public void disable_listener_by_lambda()
[Fact]
public void configure_listener()
{
ConfigureConventions(c => c.ConfigureListeners((x, _) => { x.UseDurableInbox(); }));
ConfigureConventions(c => c.ConfigureListeners((x, _) =>
{
x.UseDurableInbox();
}));

var endpoint = theRuntime.Endpoints.EndpointFor("asb://queue/routed".ToUri())
.ShouldBeOfType<AzureServiceBusQueue>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public void discover_listener_with_prefix()

var uris = runtime.Endpoints.ActiveListeners().Select(x => x.Uri).ToArray();
uris.ShouldContain(new Uri("asb://queue/zztop.routed"));
uris.ShouldContain(new Uri("asb://queue/zztop.Wolverine.AzureServiceBus.Tests.AsbMessage"));
uris.ShouldContain(new Uri("asb://queue/zztop.wolverine.azureservicebus.tests.asbmessage1"));
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
using JasperFx.Core;
using Microsoft.Extensions.Hosting;
using Oakton.Resources;
using Shouldly;
using Wolverine.ComplianceTests;
using Wolverine.Tracking;
using Xunit;

namespace Wolverine.AzureServiceBus.Tests.ConventionalRouting;

public class end_to_end_with_conventional_routing : IDisposable
public class end_to_end_with_conventional_routing : IAsyncLifetime
{
private readonly IHost _receiver;
private readonly IHost _sender;
private IHost _receiver;
private IHost _sender;

public end_to_end_with_conventional_routing()
public async Task InitializeAsync()
{
_sender = WolverineHost.For(opts =>
{
opts.UseAzureServiceBusTesting().UseConventionalRouting().AutoProvision().AutoPurgeOnStartup();
opts.DisableConventionalDiscovery();
opts.ServiceName = "Sender";
});

_receiver = WolverineHost.For(opts =>
{
opts.UseAzureServiceBusTesting().UseConventionalRouting().AutoProvision().AutoPurgeOnStartup();
opts.ServiceName = "Receiver";
});
_sender = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.UseAzureServiceBusTesting().UseConventionalRouting().AutoProvision().AutoPurgeOnStartup();
opts.DisableConventionalDiscovery();
opts.ServiceName = "Sender";

opts.Services.AddResourceSetupOnStartup();
}).StartAsync();

_receiver = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.UseAzureServiceBusTesting().UseConventionalRouting().AutoProvision().AutoPurgeOnStartup();
opts.ServiceName = "Receiver";

opts.Services.AddResourceSetupOnStartup();
}).StartAsync();
}

public void Dispose()
public async Task DisposeAsync()
{
_sender?.Dispose();
_receiver?.Dispose();
await _sender.StopAsync();
await _receiver.StopAsync();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Wolverine.AzureServiceBus.Tests.ConventionalRouting;

public class when_discovering_a_listening_endpoint_with_all_defaults : ConventionalRoutingContext
{
private readonly Uri theExpectedUri = "asb://queue/routed".ToUri();
private readonly Uri theExpectedUri = "asb://queue/routed2".ToUri();
private readonly AzureServiceBusQueue theQueue;

public when_discovering_a_listening_endpoint_with_all_defaults()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ public Task DisposeAsync()
}
}

[Collection("acceptance")]
public class InlineSendingAndReceivingCompliance : TransportCompliance<InlineComplianceFixture>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Microsoft.Extensions.Hosting;
using Wolverine.Tracking;
using Xunit;
using Xunit.Abstractions;

namespace Wolverine.AzureServiceBus.Tests;

public class clean_off_queues
{
private readonly ITestOutputHelper _output;

public clean_off_queues(ITestOutputHelper output)
{
_output = output;
}

//[Fact] -- leaving this here for later
public async Task clean_off_existing_queues()
{
using var host = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.UseAzureServiceBusTesting();
}).StartAsync();

var transport = host.GetRuntime().Options.Transports.GetOrCreate<AzureServiceBusTransport>();


while (true)
{
var queueNames = new List<string>();
await foreach (var what in transport.ManagementClient.GetQueuesAsync(CancellationToken.None))
{
queueNames.Add(what.Name);
}

if (!queueNames.Any())
{
return;
}

foreach (var queueName in queueNames)
{
await transport.ManagementClient.DeleteQueueAsync(queueName, CancellationToken.None);
_output.WriteLine("Deleted " + queueName);
}
}



}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ public Task DisposeAsync()
}
}

[Collection("acceptance")]
public class TopicAndSubscriptionSendingAndReceivingCompliance : TransportCompliance<TopicsComplianceFixture>;
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public Task DisposeAsync()
}
}

[Collection("acceptance")]
public class TopicAndSubscriptionWithCustomRuleSendingAndReceivingCompliance : TransportCompliance<TopicsWithCustomRuleComplianceFixture>
{
[Fact]
Expand Down
Loading
Loading