Skip to content

Commit

Permalink
timeout storage selector: add filesystem (#3)
Browse files Browse the repository at this point in the history
* conditional register RebusOperationMessaging
* added filesystem to DefaultTimeoutsStoreSelector
  • Loading branch information
fw2568 authored Feb 27, 2023
1 parent efd9ba3 commit c3add35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Rebus.Config;
using Rebus.Persistence.FileSystem;
using Rebus.Persistence.InMem;
using Rebus.Timeouts;

Expand All @@ -13,7 +15,7 @@ public DefaultTimeoutsStoreSelector(IConfiguration configuration, ILogger log) :
{
}

public override string[] AcceptedConfigTypes => new []{"inmemory" };
public override string[] AcceptedConfigTypes => new []{"inmemory", "filesystem" };
public override string ConfigurationName => "store";

protected override void ConfigureByType(string busType, StandardConfigurer<ITimeoutManager> configurer)
Expand All @@ -23,6 +25,14 @@ protected override void ConfigureByType(string busType, StandardConfigurer<ITime
case "inmemory":
configurer.StoreInMemory();
break;
case "filesystem":
var path = Configuration[$"{ConfigurationName}:path"];

if(path == null)
throw new InvalidOperationException($"Missing configuration entry for {ConfigurationName}::path.");

configurer.UseFileSystem(path);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static Container AddRebusOperationsHandlers(this Container container,
container.RegisterConditional<IOperationDispatcher, DefaultOperationDispatcher>(Lifestyle.Scoped,c=> !c.Handled);
container.RegisterConditional<IWorkflow, DefaultWorkflow>(Lifestyle.Scoped,c=> !c.Handled);

container.Register<IOperationMessaging, RebusOperationMessaging>(Lifestyle.Scoped);
container.RegisterConditional<IOperationMessaging, RebusOperationMessaging>(Lifestyle.Scoped, c=> !c.Handled);
container.RegisterConditional<IMessageEnricher, DefaultMessageEnricher>(Lifestyle.Scoped, c=> !c.Handled);

container.Collection.Append(typeof(IHandleMessages<>), typeof(ProcessOperationSaga), Lifestyle.Scoped);
Expand Down

0 comments on commit c3add35

Please sign in to comment.