Skip to content

Commit

Permalink
More mediator 2.0 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Sep 27, 2024
1 parent 9ea216d commit 5342db0
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 14 deletions.
7 changes: 6 additions & 1 deletion src/content/docs/client/mediator/middleware/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ We recommend configuring cache through Microsoft.Extensions.Configuration. Read
}
}
}
```
```

:::danger
Configuration does allow you to specify wildcard/globs `*` to specify all handlers in a namespace use Caching.
WE STRONGLY DISCOURAGE THIS. This feature is something you want to be very explicit about.
:::
13 changes: 8 additions & 5 deletions src/content/docs/client/mediator/middleware/offline.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Fine grained control over offline data is available via [Request Keys](../reques
```csharp
public class MyRequestHandler : IRequestHandler<MyRequest, IReadOnlyList<MyThingData>>
{
[OfflineAvailable(true)]
[OfflineAvailable]
public async Task<IReadOnlyList<MyThingData>> Handle(MyRequest request, CancellationToken cancellationToken)
{
// each return will overwrite the previous return value
Expand All @@ -44,10 +44,8 @@ Above is configured with the `OfflineAvailableAttribute`. You can also configur
```json
{
"Mediator": {
"PerformanceLogging": {
"*": {
"ErrorThresholdMilliseconds": 5000
}
"Offline": {
"MyNamespace.SomeHttpRequest": true
}
}
}
Expand All @@ -56,6 +54,11 @@ Above is configured with the `OfflineAvailableAttribute`. You can also configur
For more info about configuration, see [Middleware Configuration](./)
:::

:::danger
Configuration does allow you to specify wildcard/globs `*` to specify all handlers in a namespace use Offline.
WE STRONGLY DISCOURAGE THIS. This feature is something you want to be very explicit about.
:::

## Controlling HOW the offline data is stored

Often, there are times you want to store data based on the parameter arguments within your request. Trying to build these keys for you
Expand Down
25 changes: 21 additions & 4 deletions src/content/docs/client/mediator/middleware/refresh.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@ public class MyStreamRequestHandler : IStreamRequestHandler<MyRequest, string>
}
```

:::note
Refresh timer middleware is installed by the main Shiny.Mediator package by default
## Configuration

Much like other middleware, you can use the Microsoft.Extensions.Configuration.

```json
{
"Mediator": {
"TimerRefresh": {
"MyNamespace.MyStreamHandler": {
"IntervalSeconds": 20
}
}
}
}
```

:::danger
Configuration does allow you to specify wildcard/globs `*` to specify all handlers in a namespace use TimerRefresh.
WE STRONGLY DISCOURAGE THIS. This feature is something you want to be very explicit about.
:::


:::warning
Use this in focused areas without something like cache and offline on top of the request.
:::note
Refresh timer middleware is installed by the main Shiny.Mediator package by default
:::
11 changes: 8 additions & 3 deletions src/content/docs/client/mediator/middleware/replay.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,23 @@ await foreach (var item in stream)

## Configuration

Much like other middleware, you can use the Microsoft.Extensions.Configuration.

```json
{
"Mediator": {
"ReplayStream": {
"*": {
"AvailableAcrossSessions": true
}
"MyNamespace.MyStreamHandler": true
}
}
}
```

:::danger
Configuration does allow you to specify wildcard/globs `*` to specify all handlers in a namespace use ReplayStream.
WE STRONGLY DISCOURAGE THIS. This feature is something you want to be very explicit about.
:::

:::note
This middleware is installed by default with Shiny.Mediator.Maui or Shiny.Mediator.Blazor
:::
33 changes: 32 additions & 1 deletion src/content/docs/client/mediator/middleware/resilience.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,35 @@ For more documentation on the `Microsoft.Extension.Resilience` library, please s
```
</Steps>

That's it! Your request handler is now resilient!
That's it! Your request handler is now resilient!



### Configuration

We recommend configuring cache through Microsoft.Extensions.Configuration. Read [Configuration](./) for more information.

With the below configuration, you will also not need to configure resilience in your startup code.

```json
{
"Mediator": {
"Resilience": {
"My.Namespace.MyHandler": {
"TimeoutMilliseconds": 5000,
"Retry": {
"MaxAttempts": 3,
"UseJitter": true,
"DelayMilliseconds": 3000,
"BackoffType": "Constant"
}
}
}
}
}
```

:::danger
Configuration does allow you to specify wildcard/globs `*` to specify all handlers in a namespace use Caching.
WE STRONGLY DISCOURAGE THIS. This feature is something you want to be very explicit about.
:::
2 changes: 2 additions & 0 deletions src/content/docs/release-notes/mediator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import RN from '../../../components/ReleaseNote.astro';
<RN type="fix">Registration source generator did not default the library namespace</RN>
<RN type="fix" githubNumber={11} pr={true} contributor='osyyyS'>Shell and NRE fixes for MAUI Event Collector</RN>
<RN type="fix">OpenApiGenerator returns INT by default when no format is supplied</RN>
<RN type="chore" breaking={true}>Contract feature attributes have been removed for ReplayStream, Cache, Resilience, & Offline</RN>
<RN type="chore" breaking={true}>ReplayStream and Offline are only across sessions now</RN>
<RN type="chore" breaking={true}>TimedLoggingRequestMiddleware has been renamed to PerformanceLoggingMiddleware (including registration extensions)</RN>
<RN type="chore" breaking={true}>TimedLoggingAttribute has been removed in favour of ONLY using configuration going forward</RN>
<RN type="chore" breaking={true}>UserNotifyAttribute has been removed in favour of ONLY using configuration going forward</RN>
Expand Down

0 comments on commit 5342db0

Please sign in to comment.