Skip to content

Commit e203462

Browse files
committed
Update docs
1 parent b5043b6 commit e203462

4 files changed

Lines changed: 38 additions & 2 deletions

File tree

docs/guide/configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Configuration Options
22

3+
::: tip You Probably Don't Need This
4+
Foundatio Mediator works out of the box with sensible defaults — most projects never need to configure anything beyond `services.AddMediator()`. Only reach for the options below when you want to change a specific default behavior.
5+
:::
6+
37
Foundatio Mediator provides two types of configuration: **compile-time configuration** via the `[assembly: MediatorConfiguration]` attribute that controls source generator behavior, and **runtime configuration** via the `AddMediator()` method that controls mediator behavior.
48

59
## Compile-Time Configuration (Assembly Attribute)

docs/guide/getting-started.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Console.WriteLine(result); // Pong: Hello
5252

5353
That's it. No interfaces, no base classes, no registration — the source generator handles everything at compile time with near-direct-call performance.
5454

55+
::: tip Zero Configuration Required
56+
The defaults are optimized for the most common use cases. You do **not** need `[assembly: MediatorConfiguration]` — it exists only as an escape hatch when you want to change a specific default behavior. See [Configuration](./configuration) for the full list of options.
57+
:::
58+
5559
## Async Handlers
5660

5761
Handlers can be async and accept additional parameters resolved from DI:
@@ -108,6 +112,19 @@ HTTP methods, routes, and parameter binding are all inferred from message names
108112
app.MapMyAppEndpoints(logEndpoints: true);
109113
```
110114

115+
Need to customize a specific endpoint? Use the `[HandlerEndpoint]` attribute:
116+
117+
```csharp
118+
public class TodoHandler
119+
{
120+
[HandlerEndpoint(Route = "/todos/search", HttpMethod = "GET")]
121+
public Task<Result<Todo[]>> HandleAsync(SearchTodos query) { /* ... */ }
122+
123+
[HandlerEndpoint(Streaming = EndpointStreaming.ServerSentEvents, SseEventType = "todo")]
124+
public async IAsyncEnumerable<Todo> Handle(SubscribeToTodos msg) { /* ... */ }
125+
}
126+
```
127+
111128
See [Endpoints](./endpoints) for route customization, OpenAPI metadata, authorization, and more.
112129

113130
## Result Types
@@ -168,7 +185,16 @@ await foreach (var evt in mediator.SubscribeAsync<OrderCreated>(cancellationToke
168185
}
169186
```
170187

171-
This is ideal for streaming endpoints where each client needs its own live feed. See [Dynamic Subscriptions](./streaming-handlers#dynamic-subscriptions-with-subscribeasync) for the full API.
188+
Subscribe to **all** published notifications at once using `INotification`:
189+
190+
```csharp
191+
await foreach (var evt in mediator.SubscribeAsync<INotification>(cancellationToken: ct))
192+
{
193+
Console.WriteLine($"{evt.GetType().Name} published");
194+
}
195+
```
196+
197+
You can also subscribe to a custom marker interface (e.g., `IDispatchToClient`) to receive a targeted subset — no bridging layer or relay pipeline needed. See [Dynamic Subscriptions](./streaming-handlers#dynamic-subscriptions-with-subscribeasync) for the full API.
172198

173199
## Middleware
174200

docs/guide/handler-conventions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public class OrderProcessor { }
107107
```
108108

109109
::: tip Use Handler for Everything
110-
Unlike some libraries that distinguish between "handlers" and "consumers," Foundatio Mediator treats both identically. The `Consumer` suffix exists purely to ease migration from libraries like MassTransit. For new projects, use `Handler` consistently for commands, queries, and events alike.
110+
Unlike some libraries that distinguish between "handlers" and "consumers," Foundatio Mediator treats both identically. The `Consumer` suffix exists purely to ease migration from other mediator and message bus libraries. For new projects, use `Handler` consistently for commands, queries, and events alike.
111111
:::
112112

113113
## Method Naming Conventions

tests/Foundatio.Mediator.Tests/PublishInterceptorGenerationTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public async Task Publish(IMediator mediator) {
3434
Assert.Contains("InterceptsLocation", publishInterceptor.Source);
3535
Assert.Contains("GetPublishHandlersForType", publishInterceptor.Source);
3636
Assert.Contains("Mediator)mediator).Registry", publishInterceptor.Source);
37+
// Should fan out to dynamic subscribers
38+
Assert.Contains("TryWriteSubscription", publishInterceptor.Source);
3739
// Should have exception aggregation
3840
Assert.Contains("AggregateException", publishInterceptor.Source);
3941
// Should pass mediator to handlers
@@ -71,6 +73,8 @@ public async Task Publish(IMediator mediator) {
7173
Assert.Contains("InterceptPublishAsync_UserRegistered_", publishInterceptor.Source);
7274
Assert.Contains("GetPublishHandlersForType", publishInterceptor.Source);
7375
Assert.Contains("Mediator)mediator).Registry", publishInterceptor.Source);
76+
// Should fan out to dynamic subscribers
77+
Assert.Contains("TryWriteSubscription", publishInterceptor.Source);
7478
// TaskWhenAll should have task array and sync completion check
7579
Assert.Contains("var tasks = new", publishInterceptor.Source);
7680
Assert.Contains("IsCompletedSuccessfully", publishInterceptor.Source);
@@ -107,6 +111,8 @@ public async Task Publish(IMediator mediator) {
107111
Assert.Contains("InterceptPublishAsync_ItemDeleted_", publishInterceptor.Source);
108112
Assert.Contains("GetPublishHandlersForType", publishInterceptor.Source);
109113
Assert.Contains("Mediator)mediator).Registry", publishInterceptor.Source);
114+
// Should fan out to dynamic subscribers
115+
Assert.Contains("TryWriteSubscription", publishInterceptor.Source);
110116
// FireAndForget should use Task.Run
111117
Assert.Contains("Task.Run", publishInterceptor.Source);
112118
// And swallow exceptions

0 commit comments

Comments
 (0)