Skip to content

docs: commit 'mdsnippets' changes #1310

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

Closed
Closed
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
8 changes: 4 additions & 4 deletions docs/guide/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ something happened. Just know that as far as Wolverine is concerned, those are r
Here's a couple simple samples:

<!-- snippet: sample_DebutAccount_command -->
<a id='snippet-sample_debutaccount_command'></a>
<a id='snippet-sample_DebutAccount_command'></a>
```cs
// A "command" message
public record DebitAccount(long AccountId, decimal Amount);

// An "event" message
public record AccountOverdrawn(long AccountId);
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/DocumentationSamples/MessageBusBasics.cs#L69-L77' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_debutaccount_command' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/DocumentationSamples/MessageBusBasics.cs#L69-L77' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_DebutAccount_command' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The next concept in Wolverine is a message handler, which is just a method that "knows" how to process an incoming message. Here's an extremely
simple example:

<!-- snippet: sample_DebitAccountHandler -->
<a id='snippet-sample_debitaccounthandler'></a>
<a id='snippet-sample_DebitAccountHandler'></a>
```cs
public static class DebitAccountHandler
{
Expand All @@ -35,7 +35,7 @@ public static class DebitAccountHandler
}
}
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/DocumentationSamples/MessageBusBasics.cs#L57-L67' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_debitaccounthandler' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/DocumentationSamples/MessageBusBasics.cs#L57-L67' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_DebitAccountHandler' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Wolverine can act as a completely local mediator tool that allows your code to invoke the handler for a message at any time without having
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tools. To get started, apply Oakton as the command line parser in your applicati
sample application bootstrapping from Wolverine's [Getting Started](/tutorials/getting-started):

<!-- snippet: sample_Quickstart_Program -->
<a id='snippet-sample_quickstart_program'></a>
<a id='snippet-sample_Quickstart_Program'></a>
```cs
using Oakton;
using Quickstart;
Expand Down Expand Up @@ -47,7 +47,7 @@ app.MapGet("/", () => Results.Redirect("/swagger"));
// your Wolverine application
return await app.RunOaktonCommands(args);
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/Quickstart/Program.cs#L1-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_quickstart_program' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/Quickstart/Program.cs#L1-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_Quickstart_Program' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

From this project's root in the command line terminal tool of your choice, type:
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Below is a sample of adding Wolverine to an ASP.NET Core application that is boo
`WebApplicationBuilder`:

<!-- snippet: sample_Quickstart_Program -->
<a id='snippet-sample_quickstart_program'></a>
<a id='snippet-sample_Quickstart_Program'></a>
```cs
using Oakton;
using Quickstart;
Expand Down Expand Up @@ -77,7 +77,7 @@ app.MapGet("/", () => Results.Redirect("/swagger"));
// your Wolverine application
return await app.RunOaktonCommands(args);
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/Quickstart/Program.cs#L1-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_quickstart_program' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/Quickstart/Program.cs#L1-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_Quickstart_Program' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## "Headless" Applications
Expand Down
8 changes: 4 additions & 4 deletions docs/guide/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ to utilize this command line integration, you need to apply Oakton as your comma
sample `Program.cs` file:

<!-- snippet: sample_Quickstart_Program -->
<a id='snippet-sample_quickstart_program'></a>
<a id='snippet-sample_Quickstart_Program'></a>
```cs
using Oakton;
using Quickstart;
Expand Down Expand Up @@ -51,7 +51,7 @@ app.MapGet("/", () => Results.Redirect("/swagger"));
// your Wolverine application
return await app.RunOaktonCommands(args);
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/Quickstart/Program.cs#L1-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_quickstart_program' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/Quickstart/Program.cs#L1-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_Quickstart_Program' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## Command Line Description
Expand Down Expand Up @@ -142,14 +142,14 @@ Probably mostly for testing projects, you can verify that all the message handle
application are in a valid state by executing this method:

<!-- snippet: sample_using_AssertWolverineConfigurationIsValid -->
<a id='snippet-sample_using_assertwolverineconfigurationisvalid'></a>
<a id='snippet-sample_using_AssertWolverineConfigurationIsValid'></a>
```cs
public static void assert_configuration_is_valid(IHost host)
{
host.AssertWolverineConfigurationIsValid();
}
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/DocumentationSamples/DiagnosticSamples.cs#L8-L15' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_assertwolverineconfigurationisvalid' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/DocumentationSamples/DiagnosticSamples.cs#L8-L15' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_AssertWolverineConfigurationIsValid' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Note that this method will attempt to generate and compile the source code for each message type and use [Lamar's own
Expand Down
18 changes: 17 additions & 1 deletion docs/guide/durability/dead-letter-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,23 @@ so Wolverine does have an "opt in" feature to let old messages expire and be exp
It's off by default (for backwards compatibility), but you can enable Wolverine to assign expiration times to dead letter
queue messages persisted to durable storage like this:

snippet: sample_enabling_dead_letter_queue_expiration
<!-- snippet: sample_enabling_dead_letter_queue_expiration -->
<a id='snippet-sample_enabling_dead_letter_queue_expiration'></a>
```cs
using var host = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{

// This is required
opts.Durability.DeadLetterQueueExpirationEnabled = true;

// Default is 10 days. This is the retention period
opts.Durability.DeadLetterQueueExpiration = 3.Days();

}).StartAsync();
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Testing/CoreTests/BootstrappingSamples.cs#L41-L55' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_enabling_dead_letter_queue_expiration' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Note that Wolverine will use the message's `DeliverBy` value as the expiration if that exists, otherwise, Wolverine will
just add the `DeadLetterQueueExpiration` time to the current time. The actual stored messages are deleted by background
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/durability/idempotency.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Instead of immediately deleting message storage for a successfully completed mes
that message in storage for a default of 5 minutes to protect against duplicate incoming messages. To override that setting, you have this option:

<!-- snippet: sample_configuring_KeepAfterMessageHandling -->
<a id='snippet-sample_configuring_keepaftermessagehandling'></a>
<a id='snippet-sample_configuring_KeepAfterMessageHandling'></a>
```cs
using var host = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
Expand All @@ -25,5 +25,5 @@ using var host = await Host.CreateDefaultBuilder()
opts.Durability.KeepAfterMessageHandling = 10.Minutes();
}).StartAsync();
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Persistence/PersistenceTests/Samples/DocumentationSamples.cs#L195-L206' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_configuring_keepaftermessagehandling' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Persistence/PersistenceTests/Samples/DocumentationSamples.cs#L195-L206' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_configuring_KeepAfterMessageHandling' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
4 changes: 2 additions & 2 deletions docs/guide/durability/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ getting lost en route.
Consider this sample message handler from Wolverine's [AppWithMiddleware sample project](https://github.com/JasperFx/wolverine/tree/main/src/Samples/Middleware):

<!-- snippet: sample_DebitAccountHandler_that_uses_IMessageContext -->
<a id='snippet-sample_debitaccounthandler_that_uses_imessagecontext'></a>
<a id='snippet-sample_DebitAccountHandler_that_uses_IMessageContext'></a>
```cs
[Transactional]
public static async Task Handle(
Expand Down Expand Up @@ -62,7 +62,7 @@ public static async Task Handle(
new DeliveryOptions { DeliverWithin = 5.Seconds() });
}
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/Middleware/AppWithMiddleware/Account.cs#L126-L161' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_debitaccounthandler_that_uses_imessagecontext' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/Middleware/AppWithMiddleware/Account.cs#L126-L161' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_DebitAccountHandler_that_uses_IMessageContext' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The handler code above is committing changes to an `Account` in the underlying database and potentially sending out additional messages based on the state of the `Account`.
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/durability/marten/ancillary-stores.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Now, moving to message handlers or HTTP endpoints, you will have to explicitly t
individual messages with the `[MartenStore(store type)]` attribute like this simple example below:

<!-- snippet: sample_PlayerMessageHandler -->
<a id='snippet-sample_playermessagehandler'></a>
<a id='snippet-sample_PlayerMessageHandler'></a>
```cs
// This will use a Marten session from the
// IPlayerStore rather than the main IDocumentStore
Expand All @@ -93,7 +93,7 @@ public static class PlayerMessageHandler
}
}
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Persistence/MartenTests/AncillaryStores/bootstrapping_ancillary_marten_stores_with_wolverine.cs#L253-L267' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_playermessagehandler' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Persistence/MartenTests/AncillaryStores/bootstrapping_ancillary_marten_stores_with_wolverine.cs#L253-L267' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_PlayerMessageHandler' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

::: info
Expand Down
Loading