Skip to content

Commit

Permalink
Bumping to 1.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Nov 14, 2023
1 parent 763630f commit c245775
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<NoWarn>1570;1571;1572;1573;1574;1587;1591;1701;1702;1711;1735;0618</NoWarn>
<ImplicitUsings>true</ImplicitUsings>
<Version>1.11.0</Version>
<Version>1.11.1</Version>
<RepositoryUrl>$(PackageProjectUrl)</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// <auto-generated/>
#pragma warning disable
using Microsoft.EntityFrameworkCore;

namespace Internal.Generated.WolverineHandlers
{
// START: CreateItemCommandHandler1452615242
public class CreateItemCommandHandler1452615242 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Microsoft.EntityFrameworkCore.DbContextOptions<ItemService.ItemsDbContext> _dbContextOptions;

public CreateItemCommandHandler1452615242(Microsoft.EntityFrameworkCore.DbContextOptions<ItemService.ItemsDbContext> dbContextOptions)
{
_dbContextOptions = dbContextOptions;
}



public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation)
{
await using var itemsDbContext = new ItemService.ItemsDbContext(_dbContextOptions);
// The actual message body
var createItemCommand = (ItemService.CreateItemCommand)context.Envelope.Message;


// Enroll the DbContext & IMessagingContext in the outgoing Wolverine outbox transaction
var envelopeTransaction = Wolverine.EntityFrameworkCore.WolverineEntityCoreExtensions.BuildTransaction(itemsDbContext, context);
await context.EnlistInOutboxAsync(envelopeTransaction);

// The actual message execution
var outgoing1 = ItemService.CreateItemCommandHandler.Handle(createItemCommand, itemsDbContext);


// Outgoing, cascaded message
await context.EnqueueCascadingAsync(outgoing1).ConfigureAwait(false);


// Added by EF Core Transaction Middleware
var result_of_SaveChangesAsync = await itemsDbContext.SaveChangesAsync(cancellation).ConfigureAwait(false);

// If we have separate context for outbox and application, then we need to manually commit the transaction
if (envelopeTransaction is Wolverine.EntityFrameworkCore.Internals.RawDatabaseEnvelopeTransaction rawTx) { await rawTx.CommitAsync(); }
}

}

// END: CreateItemCommandHandler1452615242


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// <auto-generated/>
#pragma warning disable
using Lamar;

namespace Internal.Generated.WolverineHandlers
{
// START: CreateItemWithDbContextNotIntegratedWithOutboxCommandHandler300308296
public class CreateItemWithDbContextNotIntegratedWithOutboxCommandHandler300308296 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Lamar.IContainer _rootContainer;

public CreateItemWithDbContextNotIntegratedWithOutboxCommandHandler300308296(Lamar.IContainer rootContainer)
{
_rootContainer = rootContainer;
}



public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation)
{
await using var nestedContainer = (Lamar.IContainer)_rootContainer.GetNestedContainer();

/*
* Dependency: Lambda Factory of DbContextOptions<ItemService.ItemsDbContextWithoutOutbox>
* The scoping is Scoped, so a Lambda registration requires
* the usage of a nested container for resolution for correct scoping.
* A formal factory provider may be an alternative
*/
var itemsDbContextWithoutOutbox = nestedContainer.GetInstance<ItemService.ItemsDbContextWithoutOutbox>();
// The actual message body
var createItemWithDbContextNotIntegratedWithOutboxCommand = (ItemService.CreateItemWithDbContextNotIntegratedWithOutboxCommand)context.Envelope.Message;


// Enroll the DbContext & IMessagingContext in the outgoing Wolverine outbox transaction
var envelopeTransaction = Wolverine.EntityFrameworkCore.WolverineEntityCoreExtensions.BuildTransaction(itemsDbContextWithoutOutbox, context);
await context.EnlistInOutboxAsync(envelopeTransaction);

// The actual message execution
var outgoing1 = ItemService.CreateItemWithDbContextNotIntegratedWithOutboxCommandHandler.Handle(createItemWithDbContextNotIntegratedWithOutboxCommand, itemsDbContextWithoutOutbox);


// Outgoing, cascaded message
await context.EnqueueCascadingAsync(outgoing1).ConfigureAwait(false);


// Added by EF Core Transaction Middleware
var result_of_SaveChangesAsync = await itemsDbContextWithoutOutbox.SaveChangesAsync(cancellation).ConfigureAwait(false);

// If we have separate context for outbox and application, then we need to manually commit the transaction
if (envelopeTransaction is Wolverine.EntityFrameworkCore.Internals.RawDatabaseEnvelopeTransaction rawTx) { await rawTx.CommitAsync(); }
}

}

// END: CreateItemWithDbContextNotIntegratedWithOutboxCommandHandler300308296


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// <auto-generated/>
#pragma warning disable

namespace Internal.Generated.WolverineHandlers
{
// START: ItemCreatedHandler1524072513
public class ItemCreatedHandler1524072513 : Wolverine.Runtime.Handlers.MessageHandler
{


public override System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation)
{
var itemCreatedHandler = new ItemService.ItemCreatedHandler();
// The actual message body
var itemCreated = (ItemService.ItemCreated)context.Envelope.Message;


// The actual message execution
itemCreatedHandler.Handle(itemCreated);

return System.Threading.Tasks.Task.CompletedTask;
}

}

// END: ItemCreatedHandler1524072513


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// <auto-generated/>
#pragma warning disable

namespace Internal.Generated.WolverineHandlers
{
// START: ItemCreatedInDbContextNotIntegratedWithOutboxHandler659235566
public class ItemCreatedInDbContextNotIntegratedWithOutboxHandler659235566 : Wolverine.Runtime.Handlers.MessageHandler
{


public override System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation)
{
var itemCreatedInDbContextNotIntegratedWithOutboxHandler = new ItemService.ItemCreatedInDbContextNotIntegratedWithOutboxHandler();
// The actual message body
var itemCreatedInDbContextNotIntegratedWithOutbox = (ItemService.ItemCreatedInDbContextNotIntegratedWithOutbox)context.Envelope.Message;


// The actual message execution
itemCreatedInDbContextNotIntegratedWithOutboxHandler.Handle(itemCreatedInDbContextNotIntegratedWithOutbox);

return System.Threading.Tasks.Task.CompletedTask;
}

}

// END: ItemCreatedInDbContextNotIntegratedWithOutboxHandler659235566


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// <auto-generated/>
#pragma warning disable
using Microsoft.AspNetCore.Routing;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using Wolverine.Http;
using Wolverine.Runtime;

namespace Internal.Generated.WolverineHandlers
{
// START: POST_items_create4
public class POST_items_create4 : Wolverine.Http.HttpHandler
{
private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions;
private readonly Microsoft.EntityFrameworkCore.DbContextOptions<ItemService.ItemsDbContext> _dbContextOptions;
private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime;

public POST_items_create4(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Microsoft.EntityFrameworkCore.DbContextOptions<ItemService.ItemsDbContext> dbContextOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions)
{
_wolverineHttpOptions = wolverineHttpOptions;
_dbContextOptions = dbContextOptions;
_wolverineRuntime = wolverineRuntime;
}



public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext)
{
await using var itemsDbContext = new ItemService.ItemsDbContext(_dbContextOptions);
var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime);

// Enroll the DbContext & IMessagingContext in the outgoing Wolverine outbox transaction
var envelopeTransaction = Wolverine.EntityFrameworkCore.WolverineEntityCoreExtensions.BuildTransaction(itemsDbContext, messageContext);
await messageContext.EnlistInOutboxAsync(envelopeTransaction);
// Reading the request body via JSON deserialization
var (command, jsonContinue) = await ReadJsonAsync<ItemService.CreateItemCommand>(httpContext);
if (jsonContinue == Wolverine.HandlerContinuation.Stop) return;

// The actual HTTP request handler execution
var itemCreated = ItemService.CreateItemEndpoint.Post(command, itemsDbContext);


// Outgoing, cascaded message
await messageContext.EnqueueCascadingAsync(itemCreated).ConfigureAwait(false);


// Added by EF Core Transaction Middleware
var result_of_SaveChangesAsync = await itemsDbContext.SaveChangesAsync(httpContext.RequestAborted).ConfigureAwait(false);

// If we have separate context for outbox and application, then we need to manually commit the transaction
if (envelopeTransaction is Wolverine.EntityFrameworkCore.Internals.RawDatabaseEnvelopeTransaction rawTx) { await rawTx.CommitAsync(); }
// Wolverine automatically sets the status code to 204 for empty responses
if (!httpContext.Response.HasStarted) httpContext.Response.StatusCode = 204;
}

}

// END: POST_items_create4


}

0 comments on commit c245775

Please sign in to comment.