diff --git a/README.md b/README.md index 310d912..ca58235 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Register station services in your `IServiceCollection`: ```csharp builder.Services.AddTrax(trax => trax.AddEffects(effects => - effects.UsePostgres(connectionString).SaveTrainParameters().AddStepLogger(serializeStepData: true).AddStepProgress() + effects.UsePostgres(connectionString).SaveTrainParameters().AddJunctionLogger(serializeJunctionData: true).AddJunctionProgress() ) ); ``` @@ -71,19 +71,19 @@ public class CreateUserTrain : ServiceTrain, ICreateUse { protected override async Task> RunInternal(CreateUserRequest input) => Activate(input) - .Chain() - .Chain() - .Chain() + .Chain() + .Chain() + .Chain() .Resolve(); } ``` The route syntax is identical to `Train`. The difference is what happens around it — `ServiceTrain` automatically opens a journey log when the train departs, updates it when it arrives, persists effect data at each station, and records the derailment details if any stop fails. -Steps work the same way, with full DI: +Junctions work the same way, with full DI: ```csharp -public class CreateUserInDatabaseStep(AppDbContext db) : Step +public class CreateUserInDatabaseJunction(AppDbContext db) : Junction { public override async Task Run(CreateUserRequest input) { @@ -115,8 +115,8 @@ Think of it as: the train is boarding (`Pending`), in transit (`InProgress`), an | **InMemory** | `Trax.Effect.Data.InMemory` | In-memory store for tests and local dev | | **Json** | `Trax.Effect.Provider.Json` | Logs state transitions as JSON for debugging | | **Parameter** | `Trax.Effect.Provider.Parameter` | Serializes train cargo (inputs/outputs) into the journey log | -| **StepLogger** | Built-in | Logs each stop's execution with optional cargo serialization | -| **StepProgress** | Built-in | Tracks per-stop progress and checks for cancellation signals | +| **JunctionLogger** | Built-in | Logs each junction's execution with optional cargo serialization | +| **JunctionProgress** | Built-in | Tracks per-junction progress and checks for cancellation signals | Station services compose — enable as many as you need: @@ -125,8 +125,8 @@ effects .UsePostgres(connectionString) .AddJson() .SaveTrainParameters() - .AddStepLogger(serializeStepData: true) - .AddStepProgress(); + .AddJunctionLogger(serializeJunctionData: true) + .AddJunctionProgress(); ``` ## DI Registration Helpers @@ -145,7 +145,7 @@ Or use `AddMediator` (from [Trax.Mediator](https://www.nuget.org/packages/Trax.M Trax is a layered framework — each package builds on the one below it. Stop at whatever layer solves your problem. ``` -Trax.Core pipelines, steps, railway error propagation +Trax.Core pipelines, junctions, railway error propagation └→ Trax.Effect ← you are here └→ Trax.Mediator + decoupled dispatch via TrainBus └→ Trax.Scheduler + cron schedules, retries, dead-letter queues diff --git a/Trax.Effect.slnx b/Trax.Effect.slnx index a907197..2d56868 100644 --- a/Trax.Effect.slnx +++ b/Trax.Effect.slnx @@ -13,8 +13,8 @@ - - + + diff --git a/src/Trax.Effect.Data.Postgres/Extensions/ServiceExtensions.cs b/src/Trax.Effect.Data.Postgres/Extensions/ServiceExtensions.cs index 3a5b224..f029904 100644 --- a/src/Trax.Effect.Data.Postgres/Extensions/ServiceExtensions.cs +++ b/src/Trax.Effect.Data.Postgres/Extensions/ServiceExtensions.cs @@ -66,7 +66,7 @@ public static TraxEffectBuilder SkipMigrations(this TraxEffectBuilder builder) /// The configuration builder for method chaining /// /// This method configures the Trax.Effect system to use PostgreSQL for train metadata persistence. - /// It performs the following steps: + /// It performs the following operations: /// /// 1. Migrates the database schema to the latest version using the DatabaseMigrator /// 2. Creates a data source with the necessary enum mappings diff --git a/src/Trax.Effect.Data.Postgres/Migrations/029_rename_step_to_junction.sql b/src/Trax.Effect.Data.Postgres/Migrations/029_rename_step_to_junction.sql new file mode 100644 index 0000000..519d8db --- /dev/null +++ b/src/Trax.Effect.Data.Postgres/Migrations/029_rename_step_to_junction.sql @@ -0,0 +1,3 @@ +ALTER TABLE trax.metadata RENAME COLUMN failure_step TO failure_junction; +ALTER TABLE trax.metadata RENAME COLUMN step_started_at TO junction_started_at; +ALTER TABLE trax.metadata RENAME COLUMN currently_running_step TO currently_running_junction; diff --git a/src/Trax.Effect.Data.Postgres/Utils/DatabaseMigrator.cs b/src/Trax.Effect.Data.Postgres/Utils/DatabaseMigrator.cs index bc9d976..321fb4f 100644 --- a/src/Trax.Effect.Data.Postgres/Utils/DatabaseMigrator.cs +++ b/src/Trax.Effect.Data.Postgres/Utils/DatabaseMigrator.cs @@ -56,7 +56,7 @@ public static UpgradeEngine CreateEngineWithEmbeddedScripts(string connectionStr /// A task representing the asynchronous operation /// Thrown if the migration fails /// - /// This method performs the following steps: + /// This method performs the following operations: /// 1. Creates the "trax" schema if it doesn't exist /// 2. Reloads PostgreSQL types to ensure enum mappings are up-to-date /// 3. Creates a DbUp upgrade engine using the CreateEngineWithEmbeddedScripts method diff --git a/src/Trax.Effect.Data/Steps/BeginTransaction/BeginTransaction.cs b/src/Trax.Effect.Data/Junctions/BeginTransaction/BeginTransaction.cs similarity index 54% rename from src/Trax.Effect.Data/Steps/BeginTransaction/BeginTransaction.cs rename to src/Trax.Effect.Data/Junctions/BeginTransaction/BeginTransaction.cs index b19d69e..f6f5f26 100644 --- a/src/Trax.Effect.Data/Steps/BeginTransaction/BeginTransaction.cs +++ b/src/Trax.Effect.Data/Junctions/BeginTransaction/BeginTransaction.cs @@ -1,13 +1,13 @@ using LanguageExt; -using Trax.Core.Step; +using Trax.Core.Junction; using Trax.Effect.Data.Services.DataContext; -namespace Trax.Effect.Data.Steps.BeginTransaction; +namespace Trax.Effect.Data.Junctions.BeginTransaction; /// -/// Built-in step allowing for transactions to occur. +/// Built-in junction allowing for transactions to occur. /// -public class BeginTransaction(IDataContext dataContext) : Step +public class BeginTransaction(IDataContext dataContext) : Junction { public override async Task Run(Unit input) { diff --git a/src/Trax.Effect.Data/Steps/CommitTransaction/CommitTransaction.cs b/src/Trax.Effect.Data/Junctions/CommitTransaction/CommitTransaction.cs similarity index 64% rename from src/Trax.Effect.Data/Steps/CommitTransaction/CommitTransaction.cs rename to src/Trax.Effect.Data/Junctions/CommitTransaction/CommitTransaction.cs index 4d2d8f2..43eed4a 100644 --- a/src/Trax.Effect.Data/Steps/CommitTransaction/CommitTransaction.cs +++ b/src/Trax.Effect.Data/Junctions/CommitTransaction/CommitTransaction.cs @@ -1,13 +1,13 @@ using LanguageExt; -using Trax.Core.Step; +using Trax.Core.Junction; using Trax.Effect.Data.Services.DataContext; -namespace Trax.Effect.Data.Steps.CommitTransaction; +namespace Trax.Effect.Data.Junctions.CommitTransaction; /// -/// Built-in step allowing for transactions to be committed. +/// Built-in junction allowing for transactions to be committed. /// -public class CommitTransaction(IDataContext dataContextFactory) : Step +public class CommitTransaction(IDataContext dataContextFactory) : Junction { public override async Task Run(Unit input) { diff --git a/src/Trax.Effect.Data/Services/DataContext/DataContext.cs b/src/Trax.Effect.Data/Services/DataContext/DataContext.cs index 8fe23a8..6f64d41 100644 --- a/src/Trax.Effect.Data/Services/DataContext/DataContext.cs +++ b/src/Trax.Effect.Data/Services/DataContext/DataContext.cs @@ -61,7 +61,7 @@ public class DataContext(DbContextOptions options) /// This property provides access to the Log table, which stores detailed log entries /// generated during train execution. /// - /// The Logs DbSet allows for fine-grained tracking of train execution steps + /// The Logs DbSet allows for fine-grained tracking of train execution junctions /// and is particularly useful for debugging and auditing. /// public DbSet Logs { get; set; } diff --git a/src/Trax.Effect.Data/Services/DataContext/IDataContext.cs b/src/Trax.Effect.Data/Services/DataContext/IDataContext.cs index 4cd7c3e..ef33fdf 100644 --- a/src/Trax.Effect.Data/Services/DataContext/IDataContext.cs +++ b/src/Trax.Effect.Data/Services/DataContext/IDataContext.cs @@ -55,7 +55,7 @@ public interface IDataContext : IEffectProvider, IAsyncDisposable /// This property provides access to the Log table, which stores detailed log entries /// generated during train execution. /// - /// The Logs DbSet allows for fine-grained tracking of train execution steps + /// The Logs DbSet allows for fine-grained tracking of train execution junctions /// and is particularly useful for debugging and auditing. /// DbSet Logs { get; } diff --git a/src/Trax.Effect.JunctionProvider.Logging/Extensions/ServiceExtensions.cs b/src/Trax.Effect.JunctionProvider.Logging/Extensions/ServiceExtensions.cs new file mode 100644 index 0000000..5cc27b0 --- /dev/null +++ b/src/Trax.Effect.JunctionProvider.Logging/Extensions/ServiceExtensions.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.DependencyInjection; +using Trax.Effect.Extensions; +using Trax.Effect.JunctionProvider.Logging.Services.JunctionLoggerFactory; +using Trax.Effect.JunctionProvider.Logging.Services.JunctionLoggerProvider; +using TraxEffectBuilder = Trax.Effect.Configuration.TraxEffectBuilder.TraxEffectBuilder; + +namespace Trax.Effect.JunctionProvider.Logging.Extensions; + +public static class ServiceExtensions +{ + /// + /// Adds a junction-level logger that records junction names, durations, and optionally serialized input/output + /// for each junction in a train. Log entries are written at the configured effect log level. + /// + /// The builder type (supports chaining through promoted builders). + /// The effect builder. + /// + /// When true, junction input and output are serialized to JSON and included in log entries. + /// Defaults to false to avoid performance overhead. + /// + /// The builder for chaining. + public static TBuilder AddJunctionLogger( + this TBuilder configurationBuilder, + bool serializeJunctionData = false + ) + where TBuilder : TraxEffectBuilder + { + configurationBuilder.SerializeJunctionData = serializeJunctionData; + configurationBuilder.ServiceCollection.AddTransient< + IJunctionLoggerProvider, + JunctionLoggerProvider + >(); + + configurationBuilder.AddJunctionEffect(); + return configurationBuilder; + } +} diff --git a/src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerFactory/JunctionLoggerFactory.cs b/src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerFactory/JunctionLoggerFactory.cs new file mode 100644 index 0000000..6cf6ce2 --- /dev/null +++ b/src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerFactory/JunctionLoggerFactory.cs @@ -0,0 +1,13 @@ +using Microsoft.Extensions.DependencyInjection; +using Trax.Effect.JunctionProvider.Logging.Services.JunctionLoggerProvider; +using Trax.Effect.Services.JunctionEffectProvider; +using Trax.Effect.Services.JunctionEffectProviderFactory; + +namespace Trax.Effect.JunctionProvider.Logging.Services.JunctionLoggerFactory; + +public class JunctionLoggerFactory(IServiceProvider serviceProvider) + : IJunctionEffectProviderFactory +{ + public IJunctionEffectProvider Create() => + serviceProvider.GetRequiredService(); +} diff --git a/src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerProvider/IJunctionLoggerProvider.cs b/src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerProvider/IJunctionLoggerProvider.cs new file mode 100644 index 0000000..3d3f50a --- /dev/null +++ b/src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerProvider/IJunctionLoggerProvider.cs @@ -0,0 +1,5 @@ +using Trax.Effect.Services.JunctionEffectProvider; + +namespace Trax.Effect.JunctionProvider.Logging.Services.JunctionLoggerProvider; + +public interface IJunctionLoggerProvider : IJunctionEffectProvider { } diff --git a/src/Trax.Effect.StepProvider.Logging/Services/StepLoggerProvider/StepLoggerProvider.cs b/src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerProvider/JunctionLoggerProvider.cs similarity index 54% rename from src/Trax.Effect.StepProvider.Logging/Services/StepLoggerProvider/StepLoggerProvider.cs rename to src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerProvider/JunctionLoggerProvider.cs index 7beff4e..f2c4f08 100644 --- a/src/Trax.Effect.StepProvider.Logging/Services/StepLoggerProvider/StepLoggerProvider.cs +++ b/src/Trax.Effect.JunctionProvider.Logging/Services/JunctionLoggerProvider/JunctionLoggerProvider.cs @@ -2,50 +2,50 @@ using Newtonsoft.Json; using Trax.Core.Exceptions; using Trax.Effect.Configuration.TraxEffectConfiguration; -using Trax.Effect.Services.EffectStep; +using Trax.Effect.Services.EffectJunction; using Trax.Effect.Services.ServiceTrain; using JsonConverter = System.Text.Json.Serialization.JsonConverter; using JsonSerializer = System.Text.Json.JsonSerializer; -namespace Trax.Effect.StepProvider.Logging.Services.StepLoggerProvider; +namespace Trax.Effect.JunctionProvider.Logging.Services.JunctionLoggerProvider; -public class StepLoggerProvider( +public class JunctionLoggerProvider( ITraxEffectConfiguration configuration, - ILogger logger -) : IStepLoggerProvider + ILogger logger +) : IJunctionLoggerProvider { - public async Task BeforeStepExecution( - EffectStep effectStep, + public async Task BeforeJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) { - if (effectStep.Metadata is null) + if (effectJunction.Metadata is null) throw new TrainException( - "Effect Step's Metadata should be null. Something has gone horribly wrong." + "Effect Junction's Metadata should be null. Something has gone horribly wrong." ); - logger.Log(configuration.LogLevel, "{@StepMetadata}", effectStep.Metadata); + logger.Log(configuration.LogLevel, "{@JunctionMetadata}", effectJunction.Metadata); } - public async Task AfterStepExecution( - EffectStep effectStep, + public async Task AfterJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) { - if (effectStep.Metadata is null) + if (effectJunction.Metadata is null) throw new TrainException( - "Effect Step's Metadata should be null. Something has gone horribly wrong." + "Effect Junction's Metadata should be null. Something has gone horribly wrong." ); - effectStep.Result.Match( + effectJunction.Result.Match( Right: resultOut => { if (resultOut is null) return; - effectStep.Metadata.OutputJson = configuration.SerializeStepData + effectJunction.Metadata.OutputJson = configuration.SerializeJunctionData ? JsonConvert.SerializeObject( resultOut, configuration.NewtonsoftJsonSerializerSettings @@ -56,7 +56,7 @@ CancellationToken cancellationToken Bottom: () => { } ); - logger.Log(configuration.LogLevel, "{@Metadata}", effectStep.Metadata); + logger.Log(configuration.LogLevel, "{@Metadata}", effectJunction.Metadata); } public void Dispose() { } diff --git a/src/Trax.Effect.StepProvider.Logging/Trax.Effect.StepProvider.Logging.csproj b/src/Trax.Effect.JunctionProvider.Logging/Trax.Effect.JunctionProvider.Logging.csproj similarity index 76% rename from src/Trax.Effect.StepProvider.Logging/Trax.Effect.StepProvider.Logging.csproj rename to src/Trax.Effect.JunctionProvider.Logging/Trax.Effect.JunctionProvider.Logging.csproj index 7b6e7bc..dc09829 100644 --- a/src/Trax.Effect.StepProvider.Logging/Trax.Effect.StepProvider.Logging.csproj +++ b/src/Trax.Effect.JunctionProvider.Logging/Trax.Effect.JunctionProvider.Logging.csproj @@ -4,9 +4,9 @@ enable enable Theauxm,mark-keaton - Step Logging Provider for Trax.Core Effects + Junction Logging Provider for Trax.Core Effects https://github.com/TraxSharp/Trax.Effect - Trax.Effect.StepProvider.Logging + Trax.Effect.JunctionProvider.Logging diff --git a/src/Trax.Effect.JunctionProvider.Progress/Extensions/ServiceExtensions.cs b/src/Trax.Effect.JunctionProvider.Progress/Extensions/ServiceExtensions.cs new file mode 100644 index 0000000..5ebe8f7 --- /dev/null +++ b/src/Trax.Effect.JunctionProvider.Progress/Extensions/ServiceExtensions.cs @@ -0,0 +1,41 @@ +using Microsoft.Extensions.DependencyInjection; +using Trax.Effect.Extensions; +using Trax.Effect.JunctionProvider.Progress.Services.CancellationCheckFactory; +using Trax.Effect.JunctionProvider.Progress.Services.CancellationCheckProvider; +using Trax.Effect.JunctionProvider.Progress.Services.JunctionProgressFactory; +using Trax.Effect.JunctionProvider.Progress.Services.JunctionProgressProvider; +using TraxEffectBuilder = Trax.Effect.Configuration.TraxEffectBuilder.TraxEffectBuilder; + +namespace Trax.Effect.JunctionProvider.Progress.Extensions; + +public static class ServiceExtensions +{ + /// + /// Adds junction progress tracking and cancellation checking. Each junction's progress + /// (current junction index, total junctions, junction name) is persisted to metadata, and + /// the train's cancellation token is checked before each junction executes. + /// Requires a data provider (UsePostgres() or UseInMemory()). + /// + /// The builder type (supports chaining through promoted builders). + /// The effect builder. + /// The builder for chaining. + public static TBuilder AddJunctionProgress(this TBuilder configurationBuilder) + where TBuilder : TraxEffectBuilder + { + configurationBuilder.JunctionProgressEnabled = true; + + configurationBuilder.ServiceCollection.AddTransient< + ICancellationCheckProvider, + CancellationCheckProvider + >(); + configurationBuilder.ServiceCollection.AddTransient< + IJunctionProgressProvider, + JunctionProgressProvider + >(); + + // Register CancellationCheck FIRST so it runs before JunctionProgress sets columns + configurationBuilder.AddJunctionEffect(); + configurationBuilder.AddJunctionEffect(); + return configurationBuilder; + } +} diff --git a/src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckFactory/CancellationCheckFactory.cs b/src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckFactory/CancellationCheckFactory.cs new file mode 100644 index 0000000..380141b --- /dev/null +++ b/src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckFactory/CancellationCheckFactory.cs @@ -0,0 +1,13 @@ +using Microsoft.Extensions.DependencyInjection; +using Trax.Effect.JunctionProvider.Progress.Services.CancellationCheckProvider; +using Trax.Effect.Services.JunctionEffectProvider; +using Trax.Effect.Services.JunctionEffectProviderFactory; + +namespace Trax.Effect.JunctionProvider.Progress.Services.CancellationCheckFactory; + +public class CancellationCheckFactory(IServiceProvider serviceProvider) + : IJunctionEffectProviderFactory +{ + public IJunctionEffectProvider Create() => + serviceProvider.GetRequiredService(); +} diff --git a/src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckProvider/CancellationCheckProvider.cs b/src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckProvider/CancellationCheckProvider.cs similarity index 73% rename from src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckProvider/CancellationCheckProvider.cs rename to src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckProvider/CancellationCheckProvider.cs index 4d0040e..463d3db 100644 --- a/src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckProvider/CancellationCheckProvider.cs +++ b/src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckProvider/CancellationCheckProvider.cs @@ -1,15 +1,15 @@ using Microsoft.EntityFrameworkCore; using Trax.Effect.Data.Services.IDataContextFactory; -using Trax.Effect.Services.EffectStep; +using Trax.Effect.Services.EffectJunction; using Trax.Effect.Services.ServiceTrain; -namespace Trax.Effect.StepProvider.Progress.Services.CancellationCheckProvider; +namespace Trax.Effect.JunctionProvider.Progress.Services.CancellationCheckProvider; public class CancellationCheckProvider(IDataContextProviderFactory dataContextFactory) : ICancellationCheckProvider { - public async Task BeforeStepExecution( - EffectStep effectStep, + public async Task BeforeJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) @@ -28,8 +28,8 @@ CancellationToken cancellationToken throw new OperationCanceledException("Train cancellation requested via dashboard."); } - public Task AfterStepExecution( - EffectStep effectStep, + public Task AfterJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) => Task.CompletedTask; diff --git a/src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckProvider/ICancellationCheckProvider.cs b/src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckProvider/ICancellationCheckProvider.cs new file mode 100644 index 0000000..e5552a6 --- /dev/null +++ b/src/Trax.Effect.JunctionProvider.Progress/Services/CancellationCheckProvider/ICancellationCheckProvider.cs @@ -0,0 +1,5 @@ +using Trax.Effect.Services.JunctionEffectProvider; + +namespace Trax.Effect.JunctionProvider.Progress.Services.CancellationCheckProvider; + +public interface ICancellationCheckProvider : IJunctionEffectProvider { } diff --git a/src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressFactory/JunctionProgressFactory.cs b/src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressFactory/JunctionProgressFactory.cs new file mode 100644 index 0000000..8e82f0b --- /dev/null +++ b/src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressFactory/JunctionProgressFactory.cs @@ -0,0 +1,13 @@ +using Microsoft.Extensions.DependencyInjection; +using Trax.Effect.JunctionProvider.Progress.Services.JunctionProgressProvider; +using Trax.Effect.Services.JunctionEffectProvider; +using Trax.Effect.Services.JunctionEffectProviderFactory; + +namespace Trax.Effect.JunctionProvider.Progress.Services.JunctionProgressFactory; + +public class JunctionProgressFactory(IServiceProvider serviceProvider) + : IJunctionEffectProviderFactory +{ + public IJunctionEffectProvider Create() => + serviceProvider.GetRequiredService(); +} diff --git a/src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressProvider/IJunctionProgressProvider.cs b/src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressProvider/IJunctionProgressProvider.cs new file mode 100644 index 0000000..54183fb --- /dev/null +++ b/src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressProvider/IJunctionProgressProvider.cs @@ -0,0 +1,5 @@ +using Trax.Effect.Services.JunctionEffectProvider; + +namespace Trax.Effect.JunctionProvider.Progress.Services.JunctionProgressProvider; + +public interface IJunctionProgressProvider : IJunctionEffectProvider { } diff --git a/src/Trax.Effect.StepProvider.Progress/Services/StepProgressProvider/StepProgressProvider.cs b/src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressProvider/JunctionProgressProvider.cs similarity index 52% rename from src/Trax.Effect.StepProvider.Progress/Services/StepProgressProvider/StepProgressProvider.cs rename to src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressProvider/JunctionProgressProvider.cs index a61c601..e883026 100644 --- a/src/Trax.Effect.StepProvider.Progress/Services/StepProgressProvider/StepProgressProvider.cs +++ b/src/Trax.Effect.JunctionProvider.Progress/Services/JunctionProgressProvider/JunctionProgressProvider.cs @@ -1,12 +1,12 @@ -using Trax.Effect.Services.EffectStep; +using Trax.Effect.Services.EffectJunction; using Trax.Effect.Services.ServiceTrain; -namespace Trax.Effect.StepProvider.Progress.Services.StepProgressProvider; +namespace Trax.Effect.JunctionProvider.Progress.Services.JunctionProgressProvider; -public class StepProgressProvider : IStepProgressProvider +public class JunctionProgressProvider : IJunctionProgressProvider { - public async Task BeforeStepExecution( - EffectStep effectStep, + public async Task BeforeJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) @@ -14,15 +14,15 @@ CancellationToken cancellationToken if (serviceTrain.Metadata is null || serviceTrain.EffectRunner is null) return; - serviceTrain.Metadata.CurrentlyRunningStep = effectStep.Metadata?.Name; - serviceTrain.Metadata.StepStartedAt = DateTime.UtcNow; + serviceTrain.Metadata.CurrentlyRunningJunction = effectJunction.Metadata?.Name; + serviceTrain.Metadata.JunctionStartedAt = DateTime.UtcNow; await serviceTrain.EffectRunner.Update(serviceTrain.Metadata); await serviceTrain.EffectRunner.SaveChanges(cancellationToken); } - public async Task AfterStepExecution( - EffectStep effectStep, + public async Task AfterJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) @@ -30,8 +30,8 @@ CancellationToken cancellationToken if (serviceTrain.Metadata is null || serviceTrain.EffectRunner is null) return; - serviceTrain.Metadata.CurrentlyRunningStep = null; - serviceTrain.Metadata.StepStartedAt = null; + serviceTrain.Metadata.CurrentlyRunningJunction = null; + serviceTrain.Metadata.JunctionStartedAt = null; await serviceTrain.EffectRunner.Update(serviceTrain.Metadata); await serviceTrain.EffectRunner.SaveChanges(cancellationToken); diff --git a/src/Trax.Effect.StepProvider.Progress/Trax.Effect.StepProvider.Progress.csproj b/src/Trax.Effect.JunctionProvider.Progress/Trax.Effect.JunctionProvider.Progress.csproj similarity index 72% rename from src/Trax.Effect.StepProvider.Progress/Trax.Effect.StepProvider.Progress.csproj rename to src/Trax.Effect.JunctionProvider.Progress/Trax.Effect.JunctionProvider.Progress.csproj index 1db60fa..5ef3ec3 100644 --- a/src/Trax.Effect.StepProvider.Progress/Trax.Effect.StepProvider.Progress.csproj +++ b/src/Trax.Effect.JunctionProvider.Progress/Trax.Effect.JunctionProvider.Progress.csproj @@ -4,9 +4,9 @@ enable enable Theauxm,mark-keaton - Step Progress and Cancellation Check Providers for Trax.Core Effects + Junction Progress and Cancellation Check Providers for Trax.Core Effects https://github.com/TraxSharp/Trax.Effect - Trax.Effect.StepProvider.Progress + Trax.Effect.JunctionProvider.Progress diff --git a/src/Trax.Effect.Provider.Json/Extensions/ServiceExtensions.cs b/src/Trax.Effect.Provider.Json/Extensions/ServiceExtensions.cs index 11621ee..ad0ca1f 100644 --- a/src/Trax.Effect.Provider.Json/Extensions/ServiceExtensions.cs +++ b/src/Trax.Effect.Provider.Json/Extensions/ServiceExtensions.cs @@ -32,7 +32,7 @@ public static class ServiceExtensions /// tracking and logging model changes. It registers the necessary services with the /// dependency injection container. /// - /// The method performs the following steps: + /// The method performs the following operations: /// 1. Registers the JsonEffectProvider as a transient service /// 2. Registers the JsonEffectProviderFactory as an IEffectProviderFactory /// diff --git a/src/Trax.Effect.Provider.Json/Services/JsonEffect/JsonEffectProvider.cs b/src/Trax.Effect.Provider.Json/Services/JsonEffect/JsonEffectProvider.cs index 81600b5..76bfa74 100644 --- a/src/Trax.Effect.Provider.Json/Services/JsonEffect/JsonEffectProvider.cs +++ b/src/Trax.Effect.Provider.Json/Services/JsonEffect/JsonEffectProvider.cs @@ -53,7 +53,7 @@ public void Dispose() /// A cancellation token that can be used to cancel the operation /// A task representing the asynchronous operation /// - /// This method performs the following steps: + /// This method performs the following operations: /// 1. Gets the JSON serialization options from the configuration /// 2. Iterates through all tracked models /// 3. Serializes each model to JSON format diff --git a/src/Trax.Effect.Provider.Parameter/Extensions/ServiceExtensions.cs b/src/Trax.Effect.Provider.Parameter/Extensions/ServiceExtensions.cs index ee2be31..07eaf74 100644 --- a/src/Trax.Effect.Provider.Parameter/Extensions/ServiceExtensions.cs +++ b/src/Trax.Effect.Provider.Parameter/Extensions/ServiceExtensions.cs @@ -35,7 +35,7 @@ public static class ServiceExtensions /// parameters to JSON format. It registers the necessary services with the dependency /// injection container and configures the JSON serialization options. /// - /// The method performs the following steps: + /// The method performs the following operations: /// 1. Sets the JSON serializer options to use for parameter serialization /// 2. Registers the ParameterEffectProviderFactory as an IEffectProviderFactory /// diff --git a/src/Trax.Effect.Provider.Parameter/Services/ParameterEffectProviderFactory/ParameterEffectProviderFactory.cs b/src/Trax.Effect.Provider.Parameter/Services/ParameterEffectProviderFactory/ParameterEffectProviderFactory.cs index 0da24f0..e1737f3 100644 --- a/src/Trax.Effect.Provider.Parameter/Services/ParameterEffectProviderFactory/ParameterEffectProviderFactory.cs +++ b/src/Trax.Effect.Provider.Parameter/Services/ParameterEffectProviderFactory/ParameterEffectProviderFactory.cs @@ -52,7 +52,7 @@ ParameterEffectConfiguration effectConfiguration /// This method creates a new instance of ParameterEffect, which is an implementation of /// IEffectProvider that serializes train input and output parameters to JSON format. /// - /// The method performs the following steps: + /// The method performs the following operations: /// 1. Creates a new instance of ParameterEffect with the JSON serialization options from the configuration /// 2. Adds the new provider to the list of providers maintained by the factory /// 3. Returns the new provider as an IEffectProvider diff --git a/src/Trax.Effect.StepProvider.Logging/Extensions/ServiceExtensions.cs b/src/Trax.Effect.StepProvider.Logging/Extensions/ServiceExtensions.cs deleted file mode 100644 index d27d8aa..0000000 --- a/src/Trax.Effect.StepProvider.Logging/Extensions/ServiceExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Trax.Effect.Extensions; -using Trax.Effect.StepProvider.Logging.Services.StepLoggerFactory; -using Trax.Effect.StepProvider.Logging.Services.StepLoggerProvider; -using TraxEffectBuilder = Trax.Effect.Configuration.TraxEffectBuilder.TraxEffectBuilder; - -namespace Trax.Effect.StepProvider.Logging.Extensions; - -public static class ServiceExtensions -{ - /// - /// Adds a step-level logger that records step names, durations, and optionally serialized input/output - /// for each step in a train. Log entries are written at the configured effect log level. - /// - /// The builder type (supports chaining through promoted builders). - /// The effect builder. - /// - /// When true, step input and output are serialized to JSON and included in log entries. - /// Defaults to false to avoid performance overhead. - /// - /// The builder for chaining. - public static TBuilder AddStepLogger( - this TBuilder configurationBuilder, - bool serializeStepData = false - ) - where TBuilder : TraxEffectBuilder - { - configurationBuilder.SerializeStepData = serializeStepData; - configurationBuilder.ServiceCollection.AddTransient< - IStepLoggerProvider, - StepLoggerProvider - >(); - - configurationBuilder.AddStepEffect(); - return configurationBuilder; - } -} diff --git a/src/Trax.Effect.StepProvider.Logging/Services/StepLoggerFactory/StepLoggerFactory.cs b/src/Trax.Effect.StepProvider.Logging/Services/StepLoggerFactory/StepLoggerFactory.cs deleted file mode 100644 index 8dd154e..0000000 --- a/src/Trax.Effect.StepProvider.Logging/Services/StepLoggerFactory/StepLoggerFactory.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Trax.Effect.Services.StepEffectProvider; -using Trax.Effect.Services.StepEffectProviderFactory; -using Trax.Effect.StepProvider.Logging.Services.StepLoggerProvider; - -namespace Trax.Effect.StepProvider.Logging.Services.StepLoggerFactory; - -public class StepLoggerFactory(IServiceProvider serviceProvider) : IStepEffectProviderFactory -{ - public IStepEffectProvider Create() => - serviceProvider.GetRequiredService(); -} diff --git a/src/Trax.Effect.StepProvider.Logging/Services/StepLoggerProvider/IStepLoggerProvider.cs b/src/Trax.Effect.StepProvider.Logging/Services/StepLoggerProvider/IStepLoggerProvider.cs deleted file mode 100644 index 41a63b0..0000000 --- a/src/Trax.Effect.StepProvider.Logging/Services/StepLoggerProvider/IStepLoggerProvider.cs +++ /dev/null @@ -1,5 +0,0 @@ -using Trax.Effect.Services.StepEffectProvider; - -namespace Trax.Effect.StepProvider.Logging.Services.StepLoggerProvider; - -public interface IStepLoggerProvider : IStepEffectProvider { } diff --git a/src/Trax.Effect.StepProvider.Progress/Extensions/ServiceExtensions.cs b/src/Trax.Effect.StepProvider.Progress/Extensions/ServiceExtensions.cs deleted file mode 100644 index 978ac3d..0000000 --- a/src/Trax.Effect.StepProvider.Progress/Extensions/ServiceExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Trax.Effect.Extensions; -using Trax.Effect.StepProvider.Progress.Services.CancellationCheckFactory; -using Trax.Effect.StepProvider.Progress.Services.CancellationCheckProvider; -using Trax.Effect.StepProvider.Progress.Services.StepProgressFactory; -using Trax.Effect.StepProvider.Progress.Services.StepProgressProvider; -using TraxEffectBuilder = Trax.Effect.Configuration.TraxEffectBuilder.TraxEffectBuilder; - -namespace Trax.Effect.StepProvider.Progress.Extensions; - -public static class ServiceExtensions -{ - /// - /// Adds step progress tracking and cancellation checking. Each step's progress - /// (current step index, total steps, step name) is persisted to metadata, and - /// the train's cancellation token is checked before each step executes. - /// Requires a data provider (UsePostgres() or UseInMemory()). - /// - /// The builder type (supports chaining through promoted builders). - /// The effect builder. - /// The builder for chaining. - public static TBuilder AddStepProgress(this TBuilder configurationBuilder) - where TBuilder : TraxEffectBuilder - { - configurationBuilder.StepProgressEnabled = true; - - configurationBuilder.ServiceCollection.AddTransient< - ICancellationCheckProvider, - CancellationCheckProvider - >(); - configurationBuilder.ServiceCollection.AddTransient< - IStepProgressProvider, - StepProgressProvider - >(); - - // Register CancellationCheck FIRST so it runs before StepProgress sets columns - configurationBuilder.AddStepEffect(); - configurationBuilder.AddStepEffect(); - return configurationBuilder; - } -} diff --git a/src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckFactory/CancellationCheckFactory.cs b/src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckFactory/CancellationCheckFactory.cs deleted file mode 100644 index b9d382a..0000000 --- a/src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckFactory/CancellationCheckFactory.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Trax.Effect.Services.StepEffectProvider; -using Trax.Effect.Services.StepEffectProviderFactory; -using Trax.Effect.StepProvider.Progress.Services.CancellationCheckProvider; - -namespace Trax.Effect.StepProvider.Progress.Services.CancellationCheckFactory; - -public class CancellationCheckFactory(IServiceProvider serviceProvider) : IStepEffectProviderFactory -{ - public IStepEffectProvider Create() => - serviceProvider.GetRequiredService(); -} diff --git a/src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckProvider/ICancellationCheckProvider.cs b/src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckProvider/ICancellationCheckProvider.cs deleted file mode 100644 index d4b4969..0000000 --- a/src/Trax.Effect.StepProvider.Progress/Services/CancellationCheckProvider/ICancellationCheckProvider.cs +++ /dev/null @@ -1,5 +0,0 @@ -using Trax.Effect.Services.StepEffectProvider; - -namespace Trax.Effect.StepProvider.Progress.Services.CancellationCheckProvider; - -public interface ICancellationCheckProvider : IStepEffectProvider { } diff --git a/src/Trax.Effect.StepProvider.Progress/Services/StepProgressFactory/StepProgressFactory.cs b/src/Trax.Effect.StepProvider.Progress/Services/StepProgressFactory/StepProgressFactory.cs deleted file mode 100644 index ac69283..0000000 --- a/src/Trax.Effect.StepProvider.Progress/Services/StepProgressFactory/StepProgressFactory.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Trax.Effect.Services.StepEffectProvider; -using Trax.Effect.Services.StepEffectProviderFactory; -using Trax.Effect.StepProvider.Progress.Services.StepProgressProvider; - -namespace Trax.Effect.StepProvider.Progress.Services.StepProgressFactory; - -public class StepProgressFactory(IServiceProvider serviceProvider) : IStepEffectProviderFactory -{ - public IStepEffectProvider Create() => - serviceProvider.GetRequiredService(); -} diff --git a/src/Trax.Effect.StepProvider.Progress/Services/StepProgressProvider/IStepProgressProvider.cs b/src/Trax.Effect.StepProvider.Progress/Services/StepProgressProvider/IStepProgressProvider.cs deleted file mode 100644 index 72e6f7c..0000000 --- a/src/Trax.Effect.StepProvider.Progress/Services/StepProgressProvider/IStepProgressProvider.cs +++ /dev/null @@ -1,5 +0,0 @@ -using Trax.Effect.Services.StepEffectProvider; - -namespace Trax.Effect.StepProvider.Progress.Services.StepProgressProvider; - -public interface IStepProgressProvider : IStepEffectProvider { } diff --git a/src/Trax.Effect/Attributes/InjectAttribute.cs b/src/Trax.Effect/Attributes/InjectAttribute.cs index 43965aa..8a0ab14 100644 --- a/src/Trax.Effect/Attributes/InjectAttribute.cs +++ b/src/Trax.Effect/Attributes/InjectAttribute.cs @@ -8,7 +8,7 @@ namespace Trax.Effect.Attributes; /// framework-level services (like IEffectRunner, ILogger, IServiceProvider) into /// EffectTrain instances. /// -/// This attribute is NOT intended for use in user code. Steps should use standard +/// This attribute is NOT intended for use in user code. Junctions should use standard /// constructor injection for their dependencies. /// [AttributeUsage(AttributeTargets.Property)] diff --git a/src/Trax.Effect/Configuration/TraxEffectBuilder/TraxEffectBuilder.Build.cs b/src/Trax.Effect/Configuration/TraxEffectBuilder/TraxEffectBuilder.Build.cs index e366aec..fcbf9a0 100644 --- a/src/Trax.Effect/Configuration/TraxEffectBuilder/TraxEffectBuilder.Build.cs +++ b/src/Trax.Effect/Configuration/TraxEffectBuilder/TraxEffectBuilder.Build.cs @@ -4,17 +4,17 @@ public partial class TraxEffectBuilder { internal TraxEffectConfiguration.TraxEffectConfiguration Build() { - if (StepProgressEnabled && !HasDataProvider) + if (JunctionProgressEnabled && !HasDataProvider) { throw new InvalidOperationException( - "AddStepProgress() requires a data provider (UsePostgres() or UseInMemory()). " - + "Step progress tracking persists progress to metadata and checks for cancellation signals, " + "AddJunctionProgress() requires a data provider (UsePostgres() or UseInMemory()). " + + "Junction progress tracking persists progress to metadata and checks for cancellation signals, " + "which requires a data context.\n\n" + "Add a data provider to your effects configuration:\n\n" + " services.AddTrax(trax => trax\n" + " .AddEffects(effects => effects\n" + " .UsePostgres(connectionString) // or .UseInMemory()\n" - + " .AddStepProgress()\n" + + " .AddJunctionProgress()\n" + " )\n" + " );\n" ); @@ -24,7 +24,7 @@ internal TraxEffectConfiguration.TraxEffectConfiguration Build() { SystemJsonSerializerOptions = TrainParameterJsonSerializerOptions, NewtonsoftJsonSerializerSettings = NewtonsoftJsonSerializerSettings, - SerializeStepData = SerializeStepData, + SerializeJunctionData = SerializeJunctionData, LogLevel = LogLevel, }; diff --git a/src/Trax.Effect/Configuration/TraxEffectBuilder/TraxEffectBuilder.cs b/src/Trax.Effect/Configuration/TraxEffectBuilder/TraxEffectBuilder.cs index 50690d9..806f34c 100644 --- a/src/Trax.Effect/Configuration/TraxEffectBuilder/TraxEffectBuilder.cs +++ b/src/Trax.Effect/Configuration/TraxEffectBuilder/TraxEffectBuilder.cs @@ -10,7 +10,7 @@ namespace Trax.Effect.Configuration.TraxEffectBuilder; /// -/// Builder for configuring the Trax effect system (data providers, step providers, lifecycle hooks). +/// Builder for configuring the Trax effect system (data providers, junction providers, lifecycle hooks). /// /// /// After calling a data provider method (UsePostgres() or UseInMemory()), the builder @@ -37,9 +37,9 @@ internal TraxEffectBuilder(TraxEffectBuilder source) // Copy builder-level state so the promoted instance carries forward // any configuration set before promotion. MigrationsDisabled = source.MigrationsDisabled; - StepProgressEnabled = source.StepProgressEnabled; + JunctionProgressEnabled = source.JunctionProgressEnabled; DataContextLoggingEffectEnabled = source.DataContextLoggingEffectEnabled; - SerializeStepData = source.SerializeStepData; + SerializeJunctionData = source.SerializeJunctionData; LogLevel = source.LogLevel; TrainParameterJsonSerializerOptions = source.TrainParameterJsonSerializerOptions; NewtonsoftJsonSerializerSettings = source.NewtonsoftJsonSerializerSettings; @@ -88,13 +88,13 @@ public bool HasDataProvider public bool MigrationsDisabled { get; set; } [EditorBrowsable(EditorBrowsableState.Never)] - public bool StepProgressEnabled { get; set; } + public bool JunctionProgressEnabled { get; set; } [EditorBrowsable(EditorBrowsableState.Never)] public bool DataContextLoggingEffectEnabled { get; set; } = false; [EditorBrowsable(EditorBrowsableState.Never)] - public bool SerializeStepData { get; set; } = false; + public bool SerializeJunctionData { get; set; } = false; [EditorBrowsable(EditorBrowsableState.Never)] public LogLevel LogLevel { get; set; } = LogLevel.Debug; diff --git a/src/Trax.Effect/Configuration/TraxEffectConfiguration/ITraxEffectConfiguration.cs b/src/Trax.Effect/Configuration/TraxEffectConfiguration/ITraxEffectConfiguration.cs index 4b5f650..5ef1272 100644 --- a/src/Trax.Effect/Configuration/TraxEffectConfiguration/ITraxEffectConfiguration.cs +++ b/src/Trax.Effect/Configuration/TraxEffectConfiguration/ITraxEffectConfiguration.cs @@ -10,7 +10,7 @@ namespace Trax.Effect.Configuration.TraxEffectConfiguration; /// The overwhelming majority of the solution uses System.Text.Json for Serialization as it is /// much faster, and provides more granularity when it comes to serialization/deserialization. /// -/// The only current use case of Newtonsoft is Serializing arbitrary output objects in steps +/// The only current use case of Newtonsoft is Serializing arbitrary output objects in junctions /// due to its' ability to handle IDisposable objects and Circular Dependencies much better. /// public interface ITraxEffectConfiguration @@ -25,7 +25,7 @@ public interface ITraxEffectConfiguration /// public JsonSerializerSettings NewtonsoftJsonSerializerSettings { get; } - public bool SerializeStepData { get; } + public bool SerializeJunctionData { get; } public LogLevel LogLevel { get; } } diff --git a/src/Trax.Effect/Configuration/TraxEffectConfiguration/TraxEffectConfiguration.cs b/src/Trax.Effect/Configuration/TraxEffectConfiguration/TraxEffectConfiguration.cs index dca909d..9ebd423 100644 --- a/src/Trax.Effect/Configuration/TraxEffectConfiguration/TraxEffectConfiguration.cs +++ b/src/Trax.Effect/Configuration/TraxEffectConfiguration/TraxEffectConfiguration.cs @@ -16,7 +16,7 @@ public class TraxEffectConfiguration : ITraxEffectConfiguration public static JsonSerializerOptions StaticSystemJsonSerializerOptions { get; set; } = JsonSerializerOptions.Default; - public bool SerializeStepData { get; set; } = false; + public bool SerializeJunctionData { get; set; } = false; public LogLevel LogLevel { get; set; } = LogLevel.Debug; } diff --git a/src/Trax.Effect/Enums/TrainState.cs b/src/Trax.Effect/Enums/TrainState.cs index 47ef84b..bdb9365 100644 --- a/src/Trax.Effect/Enums/TrainState.cs +++ b/src/Trax.Effect/Enums/TrainState.cs @@ -49,7 +49,7 @@ public enum TrainState /// /// /// This state indicates that the train has started but has not yet completed. - /// Trains in this state are actively processing their steps. + /// Trains in this state are actively processing their junctions. /// InProgress, diff --git a/src/Trax.Effect/Extensions/ServiceExtensions.cs b/src/Trax.Effect/Extensions/ServiceExtensions.cs index dcd3b46..faf7b81 100644 --- a/src/Trax.Effect/Extensions/ServiceExtensions.cs +++ b/src/Trax.Effect/Extensions/ServiceExtensions.cs @@ -7,9 +7,9 @@ using Trax.Effect.Services.EffectProviderFactory; using Trax.Effect.Services.EffectRegistry; using Trax.Effect.Services.EffectRunner; +using Trax.Effect.Services.JunctionEffectProviderFactory; +using Trax.Effect.Services.JunctionEffectRunner; using Trax.Effect.Services.LifecycleHookRunner; -using Trax.Effect.Services.StepEffectProviderFactory; -using Trax.Effect.Services.StepEffectRunner; using Trax.Effect.Services.TrainLifecycleHookFactory; namespace Trax.Effect.Extensions; @@ -75,12 +75,12 @@ Action configure .AddSingleton(registry) .AddSingleton(effectConfig) .AddTransient() - .AddTransient() + .AddTransient() .AddTransient(); } /// - /// Configures the Trax effect system (data providers, step providers, lifecycle hooks). + /// Configures the Trax effect system (data providers, junction providers, lifecycle hooks). /// /// /// The configure function receives a and returns the @@ -90,7 +90,7 @@ Action configure /// unlocking additional methods like AddDataContextLogging(). /// /// If no data provider is configured, features that require one (such as AddScheduler() - /// or AddStepProgress()) will throw at build time with a helpful error message. + /// or AddJunctionProgress()) will throw at build time with a helpful error message. /// /// /// services.AddTrax(trax => trax @@ -123,7 +123,7 @@ Func configure /// /// /// This overload does not register a data provider. If you need data persistence - /// (required by AddScheduler(), AddStepProgress(), etc.), use + /// (required by AddScheduler(), AddJunctionProgress(), etc.), use /// the overload that accepts a configure function and call UsePostgres() /// or UseInMemory(). /// @@ -293,36 +293,40 @@ public static TraxEffectBuilder AddEffect( #endregion - #region StepEffect + #region JunctionEffect /// - /// Registers a step-level effect provider with both its interface and implementation type, - /// using an existing factory instance. Step effects run before/after each individual step. + /// Registers a junction-level effect provider with both its interface and implementation type, + /// using an existing factory instance. Junction effects run before/after each individual junction. /// - /// The step effect provider factory interface. - /// The concrete step effect provider factory type. + /// The junction effect provider factory interface. + /// The concrete junction effect provider factory type. /// The effect builder. /// The factory instance to register. /// Whether this effect can be toggled on/off at runtime. Defaults to true. /// The effect builder for chaining. - public static TraxEffectBuilder AddStepEffect< - TIStepEffectProviderFactory, - TStepEffectProviderFactory - >(this TraxEffectBuilder builder, TStepEffectProviderFactory factory, bool toggleable = true) - where TIStepEffectProviderFactory : class, IStepEffectProviderFactory - where TStepEffectProviderFactory : class, TIStepEffectProviderFactory + public static TraxEffectBuilder AddJunctionEffect< + TIJunctionEffectProviderFactory, + TJunctionEffectProviderFactory + >( + this TraxEffectBuilder builder, + TJunctionEffectProviderFactory factory, + bool toggleable = true + ) + where TIJunctionEffectProviderFactory : class, IJunctionEffectProviderFactory + where TJunctionEffectProviderFactory : class, TIJunctionEffectProviderFactory { builder - .ServiceCollection.AddSingleton(factory) - .AddSingleton(sp => - sp.GetRequiredService() + .ServiceCollection.AddSingleton(factory) + .AddSingleton(sp => + sp.GetRequiredService() ) - .AddSingleton(sp => - sp.GetRequiredService() + .AddSingleton(sp => + sp.GetRequiredService() ); builder.EffectRegistry?.Register( - typeof(TStepEffectProviderFactory), + typeof(TJunctionEffectProviderFactory), toggleable: toggleable ); @@ -330,27 +334,27 @@ public static TraxEffectBuilder AddStepEffect< } /// - /// Registers a step-level effect provider resolved from DI. - /// Step effects run before/after each individual step. + /// Registers a junction-level effect provider resolved from DI. + /// Junction effects run before/after each individual junction. /// - /// The concrete step effect provider factory type. + /// The concrete junction effect provider factory type. /// The effect builder. /// Whether this effect can be toggled on/off at runtime. Defaults to true. /// The effect builder for chaining. - public static TraxEffectBuilder AddStepEffect( + public static TraxEffectBuilder AddJunctionEffect( this TraxEffectBuilder builder, bool toggleable = true ) - where TStepEffectProviderFactory : class, IStepEffectProviderFactory + where TJunctionEffectProviderFactory : class, IJunctionEffectProviderFactory { builder - .ServiceCollection.AddSingleton() - .AddSingleton(sp => - sp.GetRequiredService() + .ServiceCollection.AddSingleton() + .AddSingleton(sp => + sp.GetRequiredService() ); builder.EffectRegistry?.Register( - typeof(TStepEffectProviderFactory), + typeof(TJunctionEffectProviderFactory), toggleable: toggleable ); @@ -358,25 +362,25 @@ public static TraxEffectBuilder AddStepEffect( } /// - /// Registers a step-level effect provider using an existing factory instance. - /// Step effects run before/after each individual step. + /// Registers a junction-level effect provider using an existing factory instance. + /// Junction effects run before/after each individual junction. /// - /// The concrete step effect provider factory type. + /// The concrete junction effect provider factory type. /// The effect builder. /// The factory instance to register. /// Whether this effect can be toggled on/off at runtime. Defaults to true. /// The effect builder for chaining. - public static TraxEffectBuilder AddStepEffect( + public static TraxEffectBuilder AddJunctionEffect( this TraxEffectBuilder builder, - TStepEffectProviderFactory factory, + TJunctionEffectProviderFactory factory, bool toggleable = true ) - where TStepEffectProviderFactory : class, IStepEffectProviderFactory + where TJunctionEffectProviderFactory : class, IJunctionEffectProviderFactory { - builder.ServiceCollection.AddSingleton(factory); + builder.ServiceCollection.AddSingleton(factory); builder.EffectRegistry?.Register( - typeof(TStepEffectProviderFactory), + typeof(TJunctionEffectProviderFactory), toggleable: toggleable ); @@ -469,15 +473,15 @@ public static TraxEffectBuilder AddLifecycleHook( #endregion - #region StepInjection + #region JunctionInjection /// - /// Registers a Trax step with scoped lifetime. The step's CanonicalName is set to + /// Registers a Trax junction with scoped lifetime. The junction's CanonicalName is set to /// 's FullName, and properties are populated. /// - /// The step interface type (used as the canonical name). - /// The concrete step implementation. - public static IServiceCollection AddScopedTraxStep( + /// The junction interface type (used as the canonical name). + /// The concrete junction implementation. + public static IServiceCollection AddScopedTraxJunction( this IServiceCollection services ) where TService : class @@ -485,24 +489,24 @@ this IServiceCollection services services.AddScopedTraxRoute(); /// - /// Registers a Trax step with scoped lifetime using runtime types. + /// Registers a Trax junction with scoped lifetime using runtime types. /// /// The service collection. - /// The step interface type (used as the canonical name). - /// The concrete step implementation type. - public static IServiceCollection AddScopedTraxStep( + /// The junction interface type (used as the canonical name). + /// The concrete junction implementation type. + public static IServiceCollection AddScopedTraxJunction( this IServiceCollection services, Type serviceInterface, Type serviceImplementation ) => services.AddScopedTraxRoute(serviceInterface, serviceImplementation); /// - /// Registers a Trax step with transient lifetime. The step's CanonicalName is set to + /// Registers a Trax junction with transient lifetime. The junction's CanonicalName is set to /// 's FullName, and properties are populated. /// - /// The step interface type (used as the canonical name). - /// The concrete step implementation. - public static IServiceCollection AddTransientTraxStep( + /// The junction interface type (used as the canonical name). + /// The concrete junction implementation. + public static IServiceCollection AddTransientTraxJunction( this IServiceCollection services ) where TService : class @@ -510,24 +514,24 @@ this IServiceCollection services services.AddTransientTraxRoute(); /// - /// Registers a Trax step with transient lifetime using runtime types. + /// Registers a Trax junction with transient lifetime using runtime types. /// /// The service collection. - /// The step interface type (used as the canonical name). - /// The concrete step implementation type. - public static IServiceCollection AddTransientTraxStep( + /// The junction interface type (used as the canonical name). + /// The concrete junction implementation type. + public static IServiceCollection AddTransientTraxJunction( this IServiceCollection services, Type serviceInterface, Type serviceImplementation ) => services.AddTransientTraxRoute(serviceInterface, serviceImplementation); /// - /// Registers a Trax step with singleton lifetime. The step's CanonicalName is set to + /// Registers a Trax junction with singleton lifetime. The junction's CanonicalName is set to /// 's FullName, and properties are populated. /// - /// The step interface type (used as the canonical name). - /// The concrete step implementation. - public static IServiceCollection AddSingletonTraxStep( + /// The junction interface type (used as the canonical name). + /// The concrete junction implementation. + public static IServiceCollection AddSingletonTraxJunction( this IServiceCollection services ) where TService : class @@ -535,12 +539,12 @@ this IServiceCollection services services.AddSingletonTraxRoute(); /// - /// Registers a Trax step with singleton lifetime using runtime types. + /// Registers a Trax junction with singleton lifetime using runtime types. /// /// The service collection. - /// The step interface type (used as the canonical name). - /// The concrete step implementation type. - public static IServiceCollection AddSingletonTraxStep( + /// The junction interface type (used as the canonical name). + /// The concrete junction implementation type. + public static IServiceCollection AddSingletonTraxJunction( this IServiceCollection services, Type serviceInterface, Type serviceImplementation @@ -551,7 +555,7 @@ Type serviceImplementation #region RouteInjection /// - /// Registers a Trax route (train or step) with scoped lifetime. Sets CanonicalName to + /// Registers a Trax route (train or junction) with scoped lifetime. Sets CanonicalName to /// 's FullName and injects properties. /// /// The route interface type (used as the canonical name). diff --git a/src/Trax.Effect/Extensions/ServiceTrainExtensions.cs b/src/Trax.Effect/Extensions/ServiceTrainExtensions.cs index 8c9a02a..069d849 100644 --- a/src/Trax.Effect/Extensions/ServiceTrainExtensions.cs +++ b/src/Trax.Effect/Extensions/ServiceTrainExtensions.cs @@ -119,8 +119,8 @@ Either result ); serviceTrain.Metadata.TrainState = resultState; serviceTrain.Metadata.EndTime = DateTime.UtcNow; - serviceTrain.Metadata.CurrentlyRunningStep = null; - serviceTrain.Metadata.StepStartedAt = null; + serviceTrain.Metadata.CurrentlyRunningJunction = null; + serviceTrain.Metadata.JunctionStartedAt = null; if (failureReason != null) serviceTrain.Metadata.AddException(failureReason); diff --git a/src/Trax.Effect/Extensions/TraxEffectConfigurationBuilderExtensions.cs b/src/Trax.Effect/Extensions/TraxEffectConfigurationBuilderExtensions.cs index 0387e34..725e2f2 100644 --- a/src/Trax.Effect/Extensions/TraxEffectConfigurationBuilderExtensions.cs +++ b/src/Trax.Effect/Extensions/TraxEffectConfigurationBuilderExtensions.cs @@ -6,7 +6,7 @@ namespace Trax.Effect.Extensions; public static class TraxEffectBuilderExtensions { /// - /// Sets the minimum log level for effect-related logging (e.g., data context operations, step effects). + /// Sets the minimum log level for effect-related logging (e.g., data context operations, junction effects). /// Defaults to . /// /// The builder type (supports chaining through promoted builders). diff --git a/src/Trax.Effect/Models/StepMetadata/DTOs/CreateStepMetadata.cs b/src/Trax.Effect/Models/JunctionMetadata/DTOs/CreateJunctionMetadata.cs similarity index 80% rename from src/Trax.Effect/Models/StepMetadata/DTOs/CreateStepMetadata.cs rename to src/Trax.Effect/Models/JunctionMetadata/DTOs/CreateJunctionMetadata.cs index 8239fb1..4081f1c 100644 --- a/src/Trax.Effect/Models/StepMetadata/DTOs/CreateStepMetadata.cs +++ b/src/Trax.Effect/Models/JunctionMetadata/DTOs/CreateJunctionMetadata.cs @@ -1,8 +1,8 @@ using LanguageExt; -namespace Trax.Effect.Models.StepMetadata.DTOs; +namespace Trax.Effect.Models.JunctionMetadata.DTOs; -public class CreateStepMetadata +public class CreateJunctionMetadata { public string Name { get; set; } = null!; public string ExternalId { get; set; } = null!; diff --git a/src/Trax.Effect/Models/StepMetadata/StepMetadata.cs b/src/Trax.Effect/Models/JunctionMetadata/JunctionMetadata.cs similarity index 67% rename from src/Trax.Effect/Models/StepMetadata/StepMetadata.cs rename to src/Trax.Effect/Models/JunctionMetadata/JunctionMetadata.cs index afafb5e..d90051f 100644 --- a/src/Trax.Effect/Models/StepMetadata/StepMetadata.cs +++ b/src/Trax.Effect/Models/JunctionMetadata/JunctionMetadata.cs @@ -3,11 +3,11 @@ using System.Text.Json.Serialization; using LanguageExt; using Trax.Effect.Configuration.TraxEffectConfiguration; -using Trax.Effect.Models.StepMetadata.DTOs; +using Trax.Effect.Models.JunctionMetadata.DTOs; -namespace Trax.Effect.Models.StepMetadata; +namespace Trax.Effect.Models.JunctionMetadata; -public class StepMetadata : IModel +public class JunctionMetadata : IModel { #region Columns @@ -55,23 +55,26 @@ public class StepMetadata : IModel #region Functions - public static StepMetadata Create(CreateStepMetadata stepMetadata, Metadata.Metadata metadata) + public static JunctionMetadata Create( + CreateJunctionMetadata junctionMetadata, + Metadata.Metadata metadata + ) { - var newStepMetadata = new StepMetadata + var newJunctionMetadata = new JunctionMetadata { - Name = stepMetadata.Name, - ExternalId = stepMetadata.ExternalId, + Name = junctionMetadata.Name, + ExternalId = junctionMetadata.ExternalId, TrainExternalId = metadata.ExternalId, TrainName = metadata.Name, - StartTimeUtc = stepMetadata.StartTimeUtc, - EndTimeUtc = stepMetadata.EndTimeUtc, - InputType = stepMetadata.InputType, - OutputType = stepMetadata.OutputType, - State = stepMetadata.State, + StartTimeUtc = junctionMetadata.StartTimeUtc, + EndTimeUtc = junctionMetadata.EndTimeUtc, + InputType = junctionMetadata.InputType, + OutputType = junctionMetadata.OutputType, + State = junctionMetadata.State, HasRan = false, }; - return newStepMetadata; + return newJunctionMetadata; } public override string ToString() => @@ -80,5 +83,5 @@ public override string ToString() => #endregion [JsonConstructor] - public StepMetadata() { } + public JunctionMetadata() { } } diff --git a/src/Trax.Effect/Models/Metadata/Metadata.cs b/src/Trax.Effect/Models/Metadata/Metadata.cs index b377e14..5a05cd7 100644 --- a/src/Trax.Effect/Models/Metadata/Metadata.cs +++ b/src/Trax.Effect/Models/Metadata/Metadata.cs @@ -25,7 +25,7 @@ namespace Trax.Effect.Models.Metadata; /// 2. Basic train information (Name, Executor) /// 3. State and timing (TrainState, StartTime, EndTime) /// 4. Input and output data (Input, Output, InputObject, OutputObject) -/// 5. Error information (FailureStep, FailureException, FailureReason, StackTrace) +/// 5. Error information (FailureJunction, FailureException, FailureReason, StackTrace) /// 6. Relationships to other entities (Parent, Children, Logs) /// /// This class is designed to be persisted to a database and serves as the @@ -105,14 +105,14 @@ public class Metadata : IModel, IDisposable public TrainState TrainState { get; set; } /// - /// Gets the name of the step where the train failed, if applicable. + /// Gets the name of the junction where the train failed, if applicable. /// /// - /// When a train fails, this property identifies the specific step + /// When a train fails, this property identifies the specific junction /// that encountered the error, making it easier to diagnose issues. /// - [Column("failure_step")] - public string? FailureStep { get; private set; } + [Column("failure_junction")] + public string? FailureJunction { get; private set; } /// /// Gets the type of exception that caused the train to fail, if applicable. @@ -209,11 +209,11 @@ public class Metadata : IModel, IDisposable [Column("cancel_requested")] public bool CancellationRequested { get; set; } - [Column("step_started_at")] - public DateTime? StepStartedAt { get; set; } + [Column("junction_started_at")] + public DateTime? JunctionStartedAt { get; set; } - [Column("currently_running_step")] - public string? CurrentlyRunningStep { get; set; } + [Column("currently_running_junction")] + public string? CurrentlyRunningJunction { get; set; } /// /// Gets or sets the hostname of the machine where the train executed. @@ -392,7 +392,7 @@ public static Metadata Create(CreateMetadata metadata) /// The method sets: /// 1. FailureException - The type of the exception /// 2. FailureReason - The error message - /// 3. FailureStep - The step where the failure occurred + /// 3. FailureJunction - The junction where the failure occurred /// 4. StackTrace - The stack trace of the exception /// /// This information is valuable for diagnosing and analyzing train failures. @@ -409,14 +409,14 @@ public Unit AddException(Exception trainException) { FailureException = trainException.GetType().Name; FailureReason = trainException.Message; - FailureStep = "TrainException"; + FailureJunction = "TrainException"; StackTrace = trainException.StackTrace; } else { FailureException = deserializedException.Type; FailureReason = deserializedException.Message; - FailureStep = deserializedException.Step; + FailureJunction = deserializedException.Junction; StackTrace = trainException.StackTrace; } @@ -426,7 +426,7 @@ public Unit AddException(Exception trainException) { FailureException = trainException.GetType().Name; FailureReason = trainException.Message; - FailureStep = "TrainException"; + FailureJunction = "TrainException"; StackTrace = trainException.StackTrace; } diff --git a/src/Trax.Effect/Services/EffectStep/EffectStep.cs b/src/Trax.Effect/Services/EffectJunction/EffectJunction.cs similarity index 54% rename from src/Trax.Effect/Services/EffectStep/EffectStep.cs rename to src/Trax.Effect/Services/EffectJunction/EffectJunction.cs index a3ea150..a9586c4 100644 --- a/src/Trax.Effect/Services/EffectStep/EffectStep.cs +++ b/src/Trax.Effect/Services/EffectJunction/EffectJunction.cs @@ -1,40 +1,40 @@ using LanguageExt; using Microsoft.Extensions.Logging; using Trax.Core.Exceptions; -using Trax.Core.Step; +using Trax.Core.Junction; using Trax.Core.Train; -using Trax.Effect.Models.StepMetadata; -using Trax.Effect.Models.StepMetadata.DTOs; +using Trax.Effect.Models.JunctionMetadata; +using Trax.Effect.Models.JunctionMetadata.DTOs; using Trax.Effect.Services.ServiceTrain; -namespace Trax.Effect.Services.EffectStep; +namespace Trax.Effect.Services.EffectJunction; -public abstract class EffectStep : Step, IEffectStep +public abstract class EffectJunction : Junction, IEffectJunction { /// - /// The core implementation method that performs the step's operation. + /// The core implementation method that performs the junction's operation. /// This must be implemented by derived classes. /// - /// The input data for this step - /// The output produced by this step + /// The input data for this junction + /// The output produced by this junction public abstract override Task Run(TIn input); - public StepMetadata? Metadata { get; private set; } + public JunctionMetadata? Metadata { get; private set; } - public override Task> RailwayStep( + public override Task> RailwayJunction( Either previousOutput, Train train ) { if (train is not ServiceTrain serviceTrain) throw new TrainException( - $"Cannot run an EffectStep ({GetType().Name}) against a non-ServiceTrain ({train.GetType().Name})" + $"Cannot run an EffectJunction ({GetType().Name}) against a non-ServiceTrain ({train.GetType().Name})" ); - return RailwayStep(previousOutput, serviceTrain); + return RailwayJunction(previousOutput, serviceTrain); } - public async Task> RailwayStep( + public async Task> RailwayJunction( Either previousOutput, ServiceTrain serviceTrain ) @@ -44,8 +44,8 @@ ServiceTrain serviceTrain "ServiceTrain Metadata cannot be null. Something has gone horribly wrong." ); - Metadata = StepMetadata.Create( - new CreateStepMetadata + Metadata = JunctionMetadata.Create( + new CreateJunctionMetadata { Name = GetType().Name, ExternalId = Guid.NewGuid().ToString("N"), @@ -56,8 +56,8 @@ ServiceTrain serviceTrain serviceTrain.Metadata ); - if (serviceTrain.StepEffectRunner is not null) - await serviceTrain.StepEffectRunner.BeforeStepExecution( + if (serviceTrain.JunctionEffectRunner is not null) + await serviceTrain.JunctionEffectRunner.BeforeJunctionExecution( this, serviceTrain, serviceTrain.CancellationToken @@ -65,14 +65,14 @@ await serviceTrain.StepEffectRunner.BeforeStepExecution( Metadata.StartTimeUtc = DateTime.UtcNow; - var result = await base.RailwayStep(previousOutput, serviceTrain); + var result = await base.RailwayJunction(previousOutput, serviceTrain); Metadata.EndTimeUtc = DateTime.UtcNow; Metadata.State = result.State; Metadata.HasRan = true; - if (serviceTrain.StepEffectRunner is not null) - await serviceTrain.StepEffectRunner.AfterStepExecution( + if (serviceTrain.JunctionEffectRunner is not null) + await serviceTrain.JunctionEffectRunner.AfterJunctionExecution( this, serviceTrain, serviceTrain.CancellationToken diff --git a/src/Trax.Effect/Services/EffectJunction/IEffectJunction.cs b/src/Trax.Effect/Services/EffectJunction/IEffectJunction.cs new file mode 100644 index 0000000..ff1ff99 --- /dev/null +++ b/src/Trax.Effect/Services/EffectJunction/IEffectJunction.cs @@ -0,0 +1,13 @@ +using LanguageExt; +using Trax.Core.Junction; +using Trax.Effect.Services.ServiceTrain; + +namespace Trax.Effect.Services.EffectJunction; + +public interface IEffectJunction : IJunction +{ + public Task> RailwayJunction( + Either previousOutput, + ServiceTrain serviceTrain + ); +} diff --git a/src/Trax.Effect/Services/EffectStep/IEffectStep.cs b/src/Trax.Effect/Services/EffectStep/IEffectStep.cs deleted file mode 100644 index 403f4bb..0000000 --- a/src/Trax.Effect/Services/EffectStep/IEffectStep.cs +++ /dev/null @@ -1,13 +0,0 @@ -using LanguageExt; -using Trax.Core.Step; -using Trax.Effect.Services.ServiceTrain; - -namespace Trax.Effect.Services.EffectStep; - -public interface IEffectStep : IStep -{ - public Task> RailwayStep( - Either previousOutput, - ServiceTrain serviceTrain - ); -} diff --git a/src/Trax.Effect/Services/JunctionEffectProvider/IJunctionEffectProvider.cs b/src/Trax.Effect/Services/JunctionEffectProvider/IJunctionEffectProvider.cs new file mode 100644 index 0000000..e386e86 --- /dev/null +++ b/src/Trax.Effect/Services/JunctionEffectProvider/IJunctionEffectProvider.cs @@ -0,0 +1,19 @@ +using Trax.Effect.Services.EffectJunction; +using Trax.Effect.Services.ServiceTrain; + +namespace Trax.Effect.Services.JunctionEffectProvider; + +public interface IJunctionEffectProvider : IDisposable +{ + Task BeforeJunctionExecution( + EffectJunction effectJunction, + ServiceTrain serviceTrain, + CancellationToken cancellationToken + ); + + Task AfterJunctionExecution( + EffectJunction effectJunction, + ServiceTrain serviceTrain, + CancellationToken cancellationToken + ); +} diff --git a/src/Trax.Effect/Services/StepEffectProviderFactory/IConfigurableStepEffectProviderFactory.cs b/src/Trax.Effect/Services/JunctionEffectProviderFactory/IConfigurableJunctionEffectProviderFactory.cs similarity index 73% rename from src/Trax.Effect/Services/StepEffectProviderFactory/IConfigurableStepEffectProviderFactory.cs rename to src/Trax.Effect/Services/JunctionEffectProviderFactory/IConfigurableJunctionEffectProviderFactory.cs index 57e44a2..9a4f129 100644 --- a/src/Trax.Effect/Services/StepEffectProviderFactory/IConfigurableStepEffectProviderFactory.cs +++ b/src/Trax.Effect/Services/JunctionEffectProviderFactory/IConfigurableJunctionEffectProviderFactory.cs @@ -1,16 +1,16 @@ using Trax.Effect.Services.EffectProviderFactory; -namespace Trax.Effect.Services.StepEffectProviderFactory; +namespace Trax.Effect.Services.JunctionEffectProviderFactory; /// -/// Extends with a strongly-typed runtime configuration. +/// Extends with a strongly-typed runtime configuration. /// Factories implementing this interface expose a singleton configuration object that can be /// inspected and modified at runtime (e.g. via the dashboard). /// /// The configuration POCO type. Must be a reference type so /// mutations to the singleton are visible to all consumers. -public interface IConfigurableStepEffectProviderFactory - : IStepEffectProviderFactory, +public interface IConfigurableJunctionEffectProviderFactory + : IJunctionEffectProviderFactory, IConfigurableProviderFactory where TConfiguration : class { diff --git a/src/Trax.Effect/Services/JunctionEffectProviderFactory/IJunctionEffectProviderFactory.cs b/src/Trax.Effect/Services/JunctionEffectProviderFactory/IJunctionEffectProviderFactory.cs new file mode 100644 index 0000000..3ba4b7d --- /dev/null +++ b/src/Trax.Effect/Services/JunctionEffectProviderFactory/IJunctionEffectProviderFactory.cs @@ -0,0 +1,8 @@ +using Trax.Effect.Services.JunctionEffectProvider; + +namespace Trax.Effect.Services.JunctionEffectProviderFactory; + +public interface IJunctionEffectProviderFactory +{ + IJunctionEffectProvider Create(); +} diff --git a/src/Trax.Effect/Services/JunctionEffectRunner/IJunctionEffectRunner.cs b/src/Trax.Effect/Services/JunctionEffectRunner/IJunctionEffectRunner.cs new file mode 100644 index 0000000..01badf4 --- /dev/null +++ b/src/Trax.Effect/Services/JunctionEffectRunner/IJunctionEffectRunner.cs @@ -0,0 +1,19 @@ +using Trax.Effect.Services.EffectJunction; +using Trax.Effect.Services.ServiceTrain; + +namespace Trax.Effect.Services.JunctionEffectRunner; + +public interface IJunctionEffectRunner : IDisposable +{ + Task BeforeJunctionExecution( + EffectJunction effectJunction, + ServiceTrain serviceTrain, + CancellationToken cancellationToken + ); + + Task AfterJunctionExecution( + EffectJunction effectJunction, + ServiceTrain serviceTrain, + CancellationToken cancellationToken + ); +} diff --git a/src/Trax.Effect/Services/StepEffectRunner/StepEffectRunner.cs b/src/Trax.Effect/Services/JunctionEffectRunner/JunctionEffectRunner.cs similarity index 55% rename from src/Trax.Effect/Services/StepEffectRunner/StepEffectRunner.cs rename to src/Trax.Effect/Services/JunctionEffectRunner/JunctionEffectRunner.cs index c31eaf4..f78d05f 100644 --- a/src/Trax.Effect/Services/StepEffectRunner/StepEffectRunner.cs +++ b/src/Trax.Effect/Services/JunctionEffectRunner/JunctionEffectRunner.cs @@ -1,54 +1,54 @@ using Microsoft.Extensions.Logging; using Trax.Effect.Extensions; +using Trax.Effect.Services.EffectJunction; using Trax.Effect.Services.EffectRegistry; -using Trax.Effect.Services.EffectStep; +using Trax.Effect.Services.JunctionEffectProvider; +using Trax.Effect.Services.JunctionEffectProviderFactory; using Trax.Effect.Services.ServiceTrain; -using Trax.Effect.Services.StepEffectProvider; -using Trax.Effect.Services.StepEffectProviderFactory; -namespace Trax.Effect.Services.StepEffectRunner; +namespace Trax.Effect.Services.JunctionEffectRunner; -public class StepEffectRunner : IStepEffectRunner +public class JunctionEffectRunner : IJunctionEffectRunner { - private List ActiveStepEffectProviders { get; init; } + private List ActiveJunctionEffectProviders { get; init; } - private readonly ILogger? _logger; + private readonly ILogger? _logger; - public StepEffectRunner( - IEnumerable stepEffectProviderFactories, + public JunctionEffectRunner( + IEnumerable junctionEffectProviderFactories, IEffectRegistry effectRegistry, - ILogger? logger = null + ILogger? logger = null ) { _logger = logger; - ActiveStepEffectProviders = []; - ActiveStepEffectProviders.AddRange( - stepEffectProviderFactories + ActiveJunctionEffectProviders = []; + ActiveJunctionEffectProviders.AddRange( + junctionEffectProviderFactories .Where(factory => effectRegistry.IsEnabled(factory.GetType())) .RunAll(factory => factory.Create()) ); } - public async Task BeforeStepExecution( - EffectStep effectStep, + public async Task BeforeJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) { - await ActiveStepEffectProviders.RunAllAsync(provider => - provider.BeforeStepExecution(effectStep, serviceTrain, cancellationToken) + await ActiveJunctionEffectProviders.RunAllAsync(provider => + provider.BeforeJunctionExecution(effectJunction, serviceTrain, cancellationToken) ); } - public async Task AfterStepExecution( - EffectStep effectStep, + public async Task AfterJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) { - await ActiveStepEffectProviders.RunAllAsync(provider => - provider.AfterStepExecution(effectStep, serviceTrain, cancellationToken) + await ActiveJunctionEffectProviders.RunAllAsync(provider => + provider.AfterJunctionExecution(effectJunction, serviceTrain, cancellationToken) ); } @@ -56,7 +56,7 @@ public void Dispose() { var disposalExceptions = new List(); - foreach (var provider in ActiveStepEffectProviders) + foreach (var provider in ActiveJunctionEffectProviders) { try { @@ -73,7 +73,7 @@ public void Dispose() } } - ActiveStepEffectProviders.Clear(); + ActiveJunctionEffectProviders.Clear(); // If we had disposal exceptions, log the summary if (disposalExceptions.Count > 0) @@ -88,7 +88,7 @@ public void Dispose() { _logger?.LogTrace( "Successfully disposed all ({ProviderCount}) effect provider(s).", - ActiveStepEffectProviders.Count + ActiveJunctionEffectProviders.Count ); } } diff --git a/src/Trax.Effect/Services/ServiceTrain/ServiceTrain.cs b/src/Trax.Effect/Services/ServiceTrain/ServiceTrain.cs index 1f4dc0c..9fc2afb 100644 --- a/src/Trax.Effect/Services/ServiceTrain/ServiceTrain.cs +++ b/src/Trax.Effect/Services/ServiceTrain/ServiceTrain.cs @@ -11,8 +11,8 @@ using Trax.Effect.Models.Metadata; using Trax.Effect.Models.Metadata.DTOs; using Trax.Effect.Services.EffectRunner; +using Trax.Effect.Services.JunctionEffectRunner; using Trax.Effect.Services.LifecycleHookRunner; -using Trax.Effect.Services.StepEffectRunner; namespace Trax.Effect.Services.ServiceTrain; @@ -48,7 +48,7 @@ public abstract class ServiceTrain : Train, IServiceTrain< [Inject] [JsonIgnore] - public IStepEffectRunner? StepEffectRunner { get; set; } + public IJunctionEffectRunner? JunctionEffectRunner { get; set; } [Inject] [JsonIgnore] @@ -96,7 +96,7 @@ public override async Task Run(TIn input, CancellationToken cancellationTo CancellationToken = cancellationToken; EffectRunner.AssertLoaded(); - StepEffectRunner.AssertLoaded(); + JunctionEffectRunner.AssertLoaded(); LifecycleHookRunner.AssertLoaded(); ServiceProvider.AssertLoaded(); @@ -192,9 +192,9 @@ CancellationToken cancellationToken protected abstract override Task> RunInternal(TIn input); /// - /// Creates a composable Monad helper with ServiceProvider for step DI. + /// Creates a composable Monad helper with ServiceProvider for junction DI. /// Overrides the base Train.Activate to inject the ServiceProvider, enabling - /// automatic dependency resolution for steps via the Chain API. + /// automatic dependency resolution for junctions via the Chain API. /// /// The primary input for the train /// Additional objects to store in the Monad's Memory @@ -214,7 +214,7 @@ public void Dispose() } EffectRunner?.Dispose(); - StepEffectRunner?.Dispose(); + JunctionEffectRunner?.Dispose(); LifecycleHookRunner?.Dispose(); Metadata?.Dispose(); diff --git a/src/Trax.Effect/Services/StepEffectProvider/IStepEffectProvider.cs b/src/Trax.Effect/Services/StepEffectProvider/IStepEffectProvider.cs deleted file mode 100644 index 36c9fd8..0000000 --- a/src/Trax.Effect/Services/StepEffectProvider/IStepEffectProvider.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Trax.Effect.Services.EffectStep; -using Trax.Effect.Services.ServiceTrain; - -namespace Trax.Effect.Services.StepEffectProvider; - -public interface IStepEffectProvider : IDisposable -{ - Task BeforeStepExecution( - EffectStep effectStep, - ServiceTrain serviceTrain, - CancellationToken cancellationToken - ); - - Task AfterStepExecution( - EffectStep effectStep, - ServiceTrain serviceTrain, - CancellationToken cancellationToken - ); -} diff --git a/src/Trax.Effect/Services/StepEffectProviderFactory/IStepEffectProviderFactory.cs b/src/Trax.Effect/Services/StepEffectProviderFactory/IStepEffectProviderFactory.cs deleted file mode 100644 index b6144c2..0000000 --- a/src/Trax.Effect/Services/StepEffectProviderFactory/IStepEffectProviderFactory.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Trax.Effect.Services.StepEffectProvider; - -namespace Trax.Effect.Services.StepEffectProviderFactory; - -public interface IStepEffectProviderFactory -{ - IStepEffectProvider Create(); -} diff --git a/src/Trax.Effect/Services/StepEffectRunner/IStepEffectRunner.cs b/src/Trax.Effect/Services/StepEffectRunner/IStepEffectRunner.cs deleted file mode 100644 index f5ac8d5..0000000 --- a/src/Trax.Effect/Services/StepEffectRunner/IStepEffectRunner.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Trax.Effect.Services.EffectStep; -using Trax.Effect.Services.ServiceTrain; - -namespace Trax.Effect.Services.StepEffectRunner; - -public interface IStepEffectRunner : IDisposable -{ - Task BeforeStepExecution( - EffectStep effectStep, - ServiceTrain serviceTrain, - CancellationToken cancellationToken - ); - - Task AfterStepExecution( - EffectStep effectStep, - ServiceTrain serviceTrain, - CancellationToken cancellationToken - ); -} diff --git a/src/Trax.Effect/Services/TrainEventBroadcaster/BroadcastLifecycleHook.cs b/src/Trax.Effect/Services/TrainEventBroadcaster/BroadcastLifecycleHook.cs index 537d3a9..fd1e3ef 100644 --- a/src/Trax.Effect/Services/TrainEventBroadcaster/BroadcastLifecycleHook.cs +++ b/src/Trax.Effect/Services/TrainEventBroadcaster/BroadcastLifecycleHook.cs @@ -61,7 +61,7 @@ private async Task PublishAsync(Metadata metadata, string eventType, Cancellatio TrainName: metadata.Name, TrainState: metadata.TrainState.ToString(), Timestamp: metadata.EndTime ?? DateTime.UtcNow, - FailureStep: metadata.FailureStep, + FailureJunction: metadata.FailureJunction, FailureReason: metadata.FailureReason, EventType: eventType, Executor: LocalExecutor, diff --git a/src/Trax.Effect/Services/TrainEventBroadcaster/TrainLifecycleEventMessage.cs b/src/Trax.Effect/Services/TrainEventBroadcaster/TrainLifecycleEventMessage.cs index 36b5382..9cf7727 100644 --- a/src/Trax.Effect/Services/TrainEventBroadcaster/TrainLifecycleEventMessage.cs +++ b/src/Trax.Effect/Services/TrainEventBroadcaster/TrainLifecycleEventMessage.cs @@ -12,7 +12,7 @@ public record TrainLifecycleEventMessage( [property: JsonPropertyName("trainName")] string TrainName, [property: JsonPropertyName("trainState")] string TrainState, [property: JsonPropertyName("timestamp")] DateTime Timestamp, - [property: JsonPropertyName("failureStep")] string? FailureStep, + [property: JsonPropertyName("failureJunction")] string? FailureJunction, [property: JsonPropertyName("failureReason")] string? FailureReason, [property: JsonPropertyName("eventType")] string EventType, [property: JsonPropertyName("executor")] string? Executor, diff --git a/tests/Trax.Effect.Tests.Benchmarks/Benchmarks/ScalingBenchmarks.cs b/tests/Trax.Effect.Tests.Benchmarks/Benchmarks/ScalingBenchmarks.cs index 7171fec..dccfc8f 100644 --- a/tests/Trax.Effect.Tests.Benchmarks/Benchmarks/ScalingBenchmarks.cs +++ b/tests/Trax.Effect.Tests.Benchmarks/Benchmarks/ScalingBenchmarks.cs @@ -7,8 +7,8 @@ namespace Trax.Effect.Tests.Benchmarks.Benchmarks; /// -/// Measures how overhead scales with step count. -/// Compares Serial vs Base Train vs EffectTrain (no effects) at 1, 3, 5, and 10 steps. +/// Measures how overhead scales with junction count. +/// Compares Serial vs Base Train vs EffectTrain (no effects) at 1, 3, 5, and 10 junctions. /// [MemoryDiagnoser] [SimpleJob(warmupCount: 3, iterationCount: 10)] @@ -17,7 +17,7 @@ public class ScalingBenchmarks private ServiceProvider _provider = null!; [Params(1, 3, 5, 10)] - public int StepCount { get; set; } + public int JunctionCount { get; set; } [GlobalSetup] public void Setup() @@ -35,11 +35,11 @@ public void Setup() public void Cleanup() => _provider.Dispose(); [Benchmark(Baseline = true, Description = "Serial")] - public Task Serial() => SerialOperations.AddNSerial(0, StepCount); + public Task Serial() => SerialOperations.AddNSerial(0, JunctionCount); [Benchmark(Description = "BaseTrain")] public Task BaseTrain() => - StepCount switch + JunctionCount switch { 1 => new AddOneX1Train().Run(0), 3 => new AddOneX3Train().Run(0), @@ -52,7 +52,7 @@ public Task BaseTrain() => public async Task EffectTrain_NoEffects() { using var scope = _provider.CreateScope(); - return StepCount switch + return JunctionCount switch { 1 => await scope.ServiceProvider.GetRequiredService().Run(0), 3 => await scope.ServiceProvider.GetRequiredService().Run(0), diff --git a/tests/Trax.Effect.Tests.Benchmarks/Benchmarks/TrainOverheadBenchmarks.cs b/tests/Trax.Effect.Tests.Benchmarks/Benchmarks/TrainOverheadBenchmarks.cs index 6375558..dd9fff6 100644 --- a/tests/Trax.Effect.Tests.Benchmarks/Benchmarks/TrainOverheadBenchmarks.cs +++ b/tests/Trax.Effect.Tests.Benchmarks/Benchmarks/TrainOverheadBenchmarks.cs @@ -50,7 +50,7 @@ public void Cleanup() _inMemoryProvider.Dispose(); } - // ===== Arithmetic: Add 1 (single step) ===== + // ===== Arithmetic: Add 1 (single junction) ===== [Benchmark(Baseline = true, Description = "Serial_Add1")] public Task Serial_AddOne() => SerialOperations.AddOneSerial(0); diff --git a/tests/Trax.Effect.Tests.Benchmarks/Junctions/AddOneJunction.cs b/tests/Trax.Effect.Tests.Benchmarks/Junctions/AddOneJunction.cs new file mode 100644 index 0000000..4a4cb5a --- /dev/null +++ b/tests/Trax.Effect.Tests.Benchmarks/Junctions/AddOneJunction.cs @@ -0,0 +1,8 @@ +using Trax.Core.Junction; + +namespace Trax.Effect.Tests.Benchmarks.Junctions; + +public class AddOneJunction : Junction +{ + public override Task Run(int input) => Task.FromResult(input + 1); +} diff --git a/tests/Trax.Effect.Tests.Benchmarks/Junctions/SimulatedIoJunction.cs b/tests/Trax.Effect.Tests.Benchmarks/Junctions/SimulatedIoJunction.cs new file mode 100644 index 0000000..828c9e6 --- /dev/null +++ b/tests/Trax.Effect.Tests.Benchmarks/Junctions/SimulatedIoJunction.cs @@ -0,0 +1,12 @@ +using Trax.Core.Junction; + +namespace Trax.Effect.Tests.Benchmarks.Junctions; + +public class SimulatedIoJunction : Junction +{ + public override async Task Run(int input) + { + await Task.Yield(); + return input + 1; + } +} diff --git a/tests/Trax.Effect.Tests.Benchmarks/Steps/TransformStep.cs b/tests/Trax.Effect.Tests.Benchmarks/Junctions/TransformJunction.cs similarity index 72% rename from tests/Trax.Effect.Tests.Benchmarks/Steps/TransformStep.cs rename to tests/Trax.Effect.Tests.Benchmarks/Junctions/TransformJunction.cs index 516920b..39b6a0e 100644 --- a/tests/Trax.Effect.Tests.Benchmarks/Steps/TransformStep.cs +++ b/tests/Trax.Effect.Tests.Benchmarks/Junctions/TransformJunction.cs @@ -1,9 +1,9 @@ -using Trax.Core.Step; +using Trax.Core.Junction; using Trax.Effect.Tests.Benchmarks.Models; -namespace Trax.Effect.Tests.Benchmarks.Steps; +namespace Trax.Effect.Tests.Benchmarks.Junctions; -public class TransformStep : Step +public class TransformJunction : Junction { public override Task Run(PersonDto input) => Task.FromResult( diff --git a/tests/Trax.Effect.Tests.Benchmarks/Steps/AddOneStep.cs b/tests/Trax.Effect.Tests.Benchmarks/Steps/AddOneStep.cs deleted file mode 100644 index f51a1bf..0000000 --- a/tests/Trax.Effect.Tests.Benchmarks/Steps/AddOneStep.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Trax.Core.Step; - -namespace Trax.Effect.Tests.Benchmarks.Steps; - -public class AddOneStep : Step -{ - public override Task Run(int input) => Task.FromResult(input + 1); -} diff --git a/tests/Trax.Effect.Tests.Benchmarks/Steps/SimulatedIoStep.cs b/tests/Trax.Effect.Tests.Benchmarks/Steps/SimulatedIoStep.cs deleted file mode 100644 index c16bb45..0000000 --- a/tests/Trax.Effect.Tests.Benchmarks/Steps/SimulatedIoStep.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Trax.Core.Step; - -namespace Trax.Effect.Tests.Benchmarks.Steps; - -public class SimulatedIoStep : Step -{ - public override async Task Run(int input) - { - await Task.Yield(); - return input + 1; - } -} diff --git a/tests/Trax.Effect.Tests.Benchmarks/Trains/EffectTrains.cs b/tests/Trax.Effect.Tests.Benchmarks/Trains/EffectTrains.cs index 70c073f..e65d32e 100644 --- a/tests/Trax.Effect.Tests.Benchmarks/Trains/EffectTrains.cs +++ b/tests/Trax.Effect.Tests.Benchmarks/Trains/EffectTrains.cs @@ -1,7 +1,7 @@ using LanguageExt; using Trax.Effect.Services.ServiceTrain; +using Trax.Effect.Tests.Benchmarks.Junctions; using Trax.Effect.Tests.Benchmarks.Models; -using Trax.Effect.Tests.Benchmarks.Steps; namespace Trax.Effect.Tests.Benchmarks.Trains; @@ -28,21 +28,25 @@ public interface IEffectAddOneX10Train : IServiceTrain; public class EffectAddOneTrain : ServiceTrain, IEffectAddOneTrain { protected override Task> RunInternal(int input) => - Task.FromResult(Activate(input).Chain().Resolve()); + Task.FromResult(Activate(input).Chain().Resolve()); } public class EffectAddThreeTrain : ServiceTrain, IEffectAddThreeTrain { protected override Task> RunInternal(int input) => Task.FromResult( - Activate(input).Chain().Chain().Chain().Resolve() + Activate(input) + .Chain() + .Chain() + .Chain() + .Resolve() ); } public class EffectTransformTrain : ServiceTrain, IEffectTransformTrain { protected override Task> RunInternal(PersonDto input) => - Task.FromResult(Activate(input).Chain().Resolve()); + Task.FromResult(Activate(input).Chain().Resolve()); } public class EffectSimulatedIoTrain : ServiceTrain, IEffectSimulatedIoTrain @@ -50,9 +54,9 @@ public class EffectSimulatedIoTrain : ServiceTrain, IEffectSimulatedIo protected override Task> RunInternal(int input) => Task.FromResult( Activate(input) - .Chain() - .Chain() - .Chain() + .Chain() + .Chain() + .Chain() .Resolve() ); } @@ -62,14 +66,18 @@ protected override Task> RunInternal(int input) => public class EffectAddOneX1Train : ServiceTrain, IEffectAddOneX1Train { protected override Task> RunInternal(int input) => - Task.FromResult(Activate(input).Chain().Resolve()); + Task.FromResult(Activate(input).Chain().Resolve()); } public class EffectAddOneX3Train : ServiceTrain, IEffectAddOneX3Train { protected override Task> RunInternal(int input) => Task.FromResult( - Activate(input).Chain().Chain().Chain().Resolve() + Activate(input) + .Chain() + .Chain() + .Chain() + .Resolve() ); } @@ -78,11 +86,11 @@ public class EffectAddOneX5Train : ServiceTrain, IEffectAddOneX5Train protected override Task> RunInternal(int input) => Task.FromResult( Activate(input) - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() .Resolve() ); } @@ -92,16 +100,16 @@ public class EffectAddOneX10Train : ServiceTrain, IEffectAddOneX10Trai protected override Task> RunInternal(int input) => Task.FromResult( Activate(input) - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() .Resolve() ); } diff --git a/tests/Trax.Effect.Tests.Benchmarks/Trains/PlainTrains.cs b/tests/Trax.Effect.Tests.Benchmarks/Trains/PlainTrains.cs index 554b5b2..bbe2d9a 100644 --- a/tests/Trax.Effect.Tests.Benchmarks/Trains/PlainTrains.cs +++ b/tests/Trax.Effect.Tests.Benchmarks/Trains/PlainTrains.cs @@ -1,7 +1,7 @@ using LanguageExt; using Trax.Core.Train; +using Trax.Effect.Tests.Benchmarks.Junctions; using Trax.Effect.Tests.Benchmarks.Models; -using Trax.Effect.Tests.Benchmarks.Steps; namespace Trax.Effect.Tests.Benchmarks.Trains; @@ -10,14 +10,18 @@ namespace Trax.Effect.Tests.Benchmarks.Trains; public class AddOneTrain : Train { protected override Task> RunInternal(int input) => - Task.FromResult(Activate(input).Chain().Resolve()); + Task.FromResult(Activate(input).Chain().Resolve()); } public class AddThreeTrain : Train { protected override Task> RunInternal(int input) => Task.FromResult( - Activate(input).Chain().Chain().Chain().Resolve() + Activate(input) + .Chain() + .Chain() + .Chain() + .Resolve() ); } @@ -26,7 +30,7 @@ protected override Task> RunInternal(int input) => public class TransformTrain : Train { protected override Task> RunInternal(PersonDto input) => - Task.FromResult(Activate(input).Chain().Resolve()); + Task.FromResult(Activate(input).Chain().Resolve()); } // --- Simulated I/O train --- @@ -36,26 +40,30 @@ public class SimulatedIoTrain : Train protected override Task> RunInternal(int input) => Task.FromResult( Activate(input) - .Chain() - .Chain() - .Chain() + .Chain() + .Chain() + .Chain() .Resolve() ); } -// --- Scaling trains (parameterized by step count) --- +// --- Scaling trains (parameterized by junction count) --- public class AddOneX1Train : Train { protected override Task> RunInternal(int input) => - Task.FromResult(Activate(input).Chain().Resolve()); + Task.FromResult(Activate(input).Chain().Resolve()); } public class AddOneX3Train : Train { protected override Task> RunInternal(int input) => Task.FromResult( - Activate(input).Chain().Chain().Chain().Resolve() + Activate(input) + .Chain() + .Chain() + .Chain() + .Resolve() ); } @@ -64,11 +72,11 @@ public class AddOneX5Train : Train protected override Task> RunInternal(int input) => Task.FromResult( Activate(input) - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() .Resolve() ); } @@ -78,16 +86,16 @@ public class AddOneX10Train : Train protected override Task> RunInternal(int input) => Task.FromResult( Activate(input) - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() - .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() + .Chain() .Resolve() ); } diff --git a/tests/Trax.Effect.Tests.Broadcaster/UnitTests/BroadcastLifecycleHookTests.cs b/tests/Trax.Effect.Tests.Broadcaster/UnitTests/BroadcastLifecycleHookTests.cs index 9adb2eb..b07cc70 100644 --- a/tests/Trax.Effect.Tests.Broadcaster/UnitTests/BroadcastLifecycleHookTests.cs +++ b/tests/Trax.Effect.Tests.Broadcaster/UnitTests/BroadcastLifecycleHookTests.cs @@ -25,7 +25,7 @@ public void SetUp() private static Metadata CreateMetadata( TrainState state = TrainState.Pending, string name = "TestTrain", - string? failureStep = null, + string? failureJunction = null, string? failureReason = null ) { @@ -199,7 +199,7 @@ await _hook.OnFailed( CancellationToken.None ); - captured!.FailureStep.Should().NotBeNull(); + captured!.FailureJunction.Should().NotBeNull(); captured.FailureReason.Should().Be("something broke"); } diff --git a/tests/Trax.Effect.Tests.Broadcaster/UnitTests/TrainEventReceiverServiceTests.cs b/tests/Trax.Effect.Tests.Broadcaster/UnitTests/TrainEventReceiverServiceTests.cs index 3e3824a..bf4d54c 100644 --- a/tests/Trax.Effect.Tests.Broadcaster/UnitTests/TrainEventReceiverServiceTests.cs +++ b/tests/Trax.Effect.Tests.Broadcaster/UnitTests/TrainEventReceiverServiceTests.cs @@ -50,7 +50,7 @@ private static TrainLifecycleEventMessage CreateMessage( TrainName: "TestTrain", TrainState: "Completed", Timestamp: DateTime.UtcNow, - FailureStep: null, + FailureJunction: null, FailureReason: null, EventType: eventType, Executor: executor, diff --git a/tests/Trax.Effect.Tests.Broadcaster/UnitTests/TrainLifecycleEventMessageTests.cs b/tests/Trax.Effect.Tests.Broadcaster/UnitTests/TrainLifecycleEventMessageTests.cs index f06be1a..d147370 100644 --- a/tests/Trax.Effect.Tests.Broadcaster/UnitTests/TrainLifecycleEventMessageTests.cs +++ b/tests/Trax.Effect.Tests.Broadcaster/UnitTests/TrainLifecycleEventMessageTests.cs @@ -16,7 +16,7 @@ public void SerializesAndDeserializesCorrectly() TrainName: "MyTrain", TrainState: "Completed", Timestamp: new DateTime(2026, 3, 6, 12, 0, 0, DateTimeKind.Utc), - FailureStep: null, + FailureJunction: null, FailureReason: null, EventType: "Completed", Executor: "TestWorker", @@ -33,7 +33,7 @@ public void SerializesAndDeserializesCorrectly() deserialized.TrainState.Should().Be("Completed"); deserialized.EventType.Should().Be("Completed"); deserialized.Executor.Should().Be("TestWorker"); - deserialized.FailureStep.Should().BeNull(); + deserialized.FailureJunction.Should().BeNull(); deserialized.FailureReason.Should().BeNull(); deserialized.Output.Should().Be("{\"result\":\"success\"}"); } @@ -47,7 +47,7 @@ public void SerializesWithFailureDetails() TrainName: "FailingTrain", TrainState: "Failed", Timestamp: DateTime.UtcNow, - FailureStep: "StepA", + FailureJunction: "JunctionA", FailureReason: "Something went wrong", EventType: "Failed", Executor: "Worker1", @@ -57,7 +57,7 @@ public void SerializesWithFailureDetails() var json = JsonSerializer.Serialize(message); var deserialized = JsonSerializer.Deserialize(json); - deserialized!.FailureStep.Should().Be("StepA"); + deserialized!.FailureJunction.Should().Be("JunctionA"); deserialized.FailureReason.Should().Be("Something went wrong"); } @@ -70,7 +70,7 @@ public void SerializesNullExecutor() TrainName: "OrphanTrain", TrainState: "Completed", Timestamp: DateTime.UtcNow, - FailureStep: null, + FailureJunction: null, FailureReason: null, EventType: "Completed", Executor: null, @@ -92,7 +92,7 @@ public void UsesJsonPropertyNames() TrainName: "Train", TrainState: "Completed", Timestamp: DateTime.UtcNow, - FailureStep: null, + FailureJunction: null, FailureReason: null, EventType: "Completed", Executor: "Worker", diff --git a/tests/Trax.Effect.Tests.Data.InMemory.Integration/IntegrationTests/DataContextChangeTrackingTests.cs b/tests/Trax.Effect.Tests.Data.InMemory.Integration/IntegrationTests/DataContextChangeTrackingTests.cs index d1b86f3..c5b85d0 100644 --- a/tests/Trax.Effect.Tests.Data.InMemory.Integration/IntegrationTests/DataContextChangeTrackingTests.cs +++ b/tests/Trax.Effect.Tests.Data.InMemory.Integration/IntegrationTests/DataContextChangeTrackingTests.cs @@ -253,7 +253,7 @@ public async Task FullFlow_FailedTrain_PersistsFailureState() [Test] public async Task CrossContext_EntitySavedInOneContext_CanBeTrackedByAnother() { - // Simulates the scheduler flow where metadata is loaded by LoadMetadataStep's + // Simulates the scheduler flow where metadata is loaded by LoadMetadataJunction's // context, then passed to the inner train's EffectRunner context. var dbName = nameof(CrossContext_EntitySavedInOneContext_CanBeTrackedByAnother); @@ -264,7 +264,7 @@ public async Task CrossContext_EntitySavedInOneContext_CanBeTrackedByAnother() await contextA.SaveChanges(CancellationToken.None); var savedId = metadata.Id; - // Load from DB in context A (like LoadMetadataStep) + // Load from DB in context A (like LoadMetadataJunction) contextA.Reset(); var loaded = await contextA.Metadatas.FirstAsync(x => x.Id == savedId); diff --git a/tests/Trax.Effect.Tests.Data.InMemory.Integration/IntegrationTests/InMemoryProviderTests.cs b/tests/Trax.Effect.Tests.Data.InMemory.Integration/IntegrationTests/InMemoryProviderTests.cs index 4a14bf4..167f683 100644 --- a/tests/Trax.Effect.Tests.Data.InMemory.Integration/IntegrationTests/InMemoryProviderTests.cs +++ b/tests/Trax.Effect.Tests.Data.InMemory.Integration/IntegrationTests/InMemoryProviderTests.cs @@ -236,7 +236,7 @@ public async Task Run_CompletedTrain_PersistsCorrectMetadata() train.Metadata.TrainState.Should().Be(TrainState.Completed); train.Metadata.FailureException.Should().BeNullOrEmpty(); train.Metadata.FailureReason.Should().BeNullOrEmpty(); - train.Metadata.FailureStep.Should().BeNullOrEmpty(); + train.Metadata.FailureJunction.Should().BeNullOrEmpty(); train.Metadata.Id.Should().BeGreaterThan(0); train.Metadata.StartTime.Should().NotBe(default); train.Metadata.EndTime.Should().NotBeNull(); diff --git a/tests/Trax.Effect.Tests.Integration/Fixtures/TestSetup.cs b/tests/Trax.Effect.Tests.Integration/Fixtures/TestSetup.cs index 020bd9c..b8a8223 100644 --- a/tests/Trax.Effect.Tests.Integration/Fixtures/TestSetup.cs +++ b/tests/Trax.Effect.Tests.Integration/Fixtures/TestSetup.cs @@ -7,9 +7,9 @@ using Trax.Effect.Data.Services.DataContext; using Trax.Effect.Data.Services.IDataContextFactory; using Trax.Effect.Extensions; +using Trax.Effect.JunctionProvider.Logging.Extensions; using Trax.Effect.Provider.Json.Extensions; using Trax.Effect.Provider.Parameter.Extensions; -using Trax.Effect.StepProvider.Logging.Extensions; namespace Trax.Effect.Tests.Integration.Fixtures; @@ -43,7 +43,7 @@ public async Task RunBeforeAnyTests() .UsePostgres(connectionString) .AddDataContextLogging(minimumLogLevel: LogLevel.Trace) .AddJson() - .AddStepLogger(serializeStepData: true) + .AddJunctionLogger(serializeJunctionData: true) ) ) .BuildServiceProvider(); diff --git a/tests/Trax.Effect.Tests.Integration/Trax.Effect.Tests.Integration.csproj b/tests/Trax.Effect.Tests.Integration/Trax.Effect.Tests.Integration.csproj index 1f9cc1e..1499469 100644 --- a/tests/Trax.Effect.Tests.Integration/Trax.Effect.Tests.Integration.csproj +++ b/tests/Trax.Effect.Tests.Integration/Trax.Effect.Tests.Integration.csproj @@ -39,8 +39,8 @@ - - + + diff --git a/tests/Trax.Effect.Tests.Integration/UnitTests/Configuration/SaneDefaultsTests.cs b/tests/Trax.Effect.Tests.Integration/UnitTests/Configuration/SaneDefaultsTests.cs index 6089a80..073d39a 100644 --- a/tests/Trax.Effect.Tests.Integration/UnitTests/Configuration/SaneDefaultsTests.cs +++ b/tests/Trax.Effect.Tests.Integration/UnitTests/Configuration/SaneDefaultsTests.cs @@ -7,11 +7,11 @@ using Trax.Effect.Data.InMemory.Extensions; using Trax.Effect.Data.Postgres.Extensions; using Trax.Effect.Extensions; +using Trax.Effect.JunctionProvider.Logging.Extensions; +using Trax.Effect.JunctionProvider.Progress.Extensions; using Trax.Effect.Provider.Json.Extensions; using Trax.Effect.Provider.Parameter.Extensions; using Trax.Effect.Services.EffectRegistry; -using Trax.Effect.StepProvider.Logging.Extensions; -using Trax.Effect.StepProvider.Progress.Extensions; namespace Trax.Effect.Tests.Integration.UnitTests.Configuration; @@ -145,7 +145,7 @@ public void SaveTrainParameters_PreservesTraxEffectBuilderWithData() } [Test] - public void AddStepProgress_PreservesTraxEffectBuilderWithData() + public void AddJunctionProgress_PreservesTraxEffectBuilderWithData() { var services = new ServiceCollection(); services.AddLogging(); @@ -155,7 +155,7 @@ public void AddStepProgress_PreservesTraxEffectBuilderWithData() services.AddTrax(trax => trax.AddEffects(effects => { - var result = effects.UseInMemory().AddStepProgress(); + var result = effects.UseInMemory().AddJunctionProgress(); capturedBuilder = result; return result; }) @@ -165,7 +165,7 @@ public void AddStepProgress_PreservesTraxEffectBuilderWithData() } [Test] - public void AddStepLogger_PreservesTraxEffectBuilderWithData() + public void AddJunctionLogger_PreservesTraxEffectBuilderWithData() { var services = new ServiceCollection(); services.AddLogging(); @@ -175,7 +175,7 @@ public void AddStepLogger_PreservesTraxEffectBuilderWithData() services.AddTrax(trax => trax.AddEffects(effects => { - var result = effects.UseInMemory().AddStepLogger(); + var result = effects.UseInMemory().AddJunctionLogger(); capturedBuilder = result; return result; }) @@ -218,8 +218,8 @@ public void FullChain_PreservesTraxEffectBuilderWithData() .UseInMemory() .AddJson() .SaveTrainParameters() - .AddStepProgress() - .AddStepLogger() + .AddJunctionProgress() + .AddJunctionLogger() .SetEffectLogLevel(LogLevel.Trace); capturedBuilder = result; return result; @@ -353,40 +353,40 @@ public void TraxBuilderWithEffects_AfterUseInMemory_HasDataProviderTrue() #endregion - #region AddStepProgress Build-Time Validation + #region AddJunctionProgress Build-Time Validation [Test] - public void AddStepProgress_WithoutDataProvider_ThrowsWithHelpfulMessage() + public void AddJunctionProgress_WithoutDataProvider_ThrowsWithHelpfulMessage() { var services = new ServiceCollection(); services.AddLogging(); var act = () => - services.AddTrax(trax => trax.AddEffects(effects => effects.AddStepProgress())); + services.AddTrax(trax => trax.AddEffects(effects => effects.AddJunctionProgress())); act.Should() .Throw() - .WithMessage("*AddStepProgress()*") + .WithMessage("*AddJunctionProgress()*") .WithMessage("*UsePostgres*") .WithMessage("*UseInMemory*"); } [Test] - public void AddStepProgress_WithInMemory_DoesNotThrow() + public void AddJunctionProgress_WithInMemory_DoesNotThrow() { var services = new ServiceCollection(); services.AddLogging(); var act = () => services.AddTrax(trax => - trax.AddEffects(effects => effects.UseInMemory().AddStepProgress()) + trax.AddEffects(effects => effects.UseInMemory().AddJunctionProgress()) ); act.Should().NotThrow(); } [Test] - public void AddStepProgress_BeforeDataProvider_StillPasses() + public void AddJunctionProgress_BeforeDataProvider_StillPasses() { // Validation runs at Build() time, after the lambda returns, // so ordering within the lambda doesn't matter. @@ -397,7 +397,7 @@ public void AddStepProgress_BeforeDataProvider_StillPasses() services.AddTrax(trax => trax.AddEffects(effects => { - effects.AddStepProgress(); + effects.AddJunctionProgress(); return effects.UseInMemory(); }) ); @@ -406,13 +406,13 @@ public void AddStepProgress_BeforeDataProvider_StillPasses() } [Test] - public void AddStepProgress_ErrorMessage_ContainsCodeExample() + public void AddJunctionProgress_ErrorMessage_ContainsCodeExample() { var services = new ServiceCollection(); services.AddLogging(); var act = () => - services.AddTrax(trax => trax.AddEffects(effects => effects.AddStepProgress())); + services.AddTrax(trax => trax.AddEffects(effects => effects.AddJunctionProgress())); act.Should() .Throw() diff --git a/tests/Trax.Effect.Tests.Integration/UnitTests/Configuration/TraxEffectConfigurationBuilderTests.cs b/tests/Trax.Effect.Tests.Integration/UnitTests/Configuration/TraxEffectConfigurationBuilderTests.cs index 27ad4ae..8d15a4c 100644 --- a/tests/Trax.Effect.Tests.Integration/UnitTests/Configuration/TraxEffectConfigurationBuilderTests.cs +++ b/tests/Trax.Effect.Tests.Integration/UnitTests/Configuration/TraxEffectConfigurationBuilderTests.cs @@ -24,7 +24,7 @@ public void AddTrax_WithDefaults_RegistersEffectConfiguration() var config = provider.GetRequiredService(); config.Should().NotBeNull(); config.LogLevel.Should().Be(LogLevel.Debug); - config.SerializeStepData.Should().BeFalse(); + config.SerializeJunctionData.Should().BeFalse(); } [Test] diff --git a/tests/Trax.Effect.Tests.Integration/UnitTests/Extensions/ServiceExtensionsRegistrationTests.cs b/tests/Trax.Effect.Tests.Integration/UnitTests/Extensions/ServiceExtensionsRegistrationTests.cs index 02ef71b..208a6da 100644 --- a/tests/Trax.Effect.Tests.Integration/UnitTests/Extensions/ServiceExtensionsRegistrationTests.cs +++ b/tests/Trax.Effect.Tests.Integration/UnitTests/Extensions/ServiceExtensionsRegistrationTests.cs @@ -1,8 +1,8 @@ using FluentAssertions; using LanguageExt; using Microsoft.Extensions.DependencyInjection; +using Trax.Core.Junction; using Trax.Core.Route; -using Trax.Core.Step; using Trax.Effect.Extensions; using Trax.Effect.Services.ServiceTrain; @@ -12,51 +12,51 @@ namespace Trax.Effect.Tests.Integration.UnitTests.Extensions; public class ServiceExtensionsRegistrationTests { [Test] - public void AddScopedTraxStep_Resolves_ViaInterface() + public void AddScopedTraxJunction_Resolves_ViaInterface() { // Arrange var services = new ServiceCollection(); - services.AddScopedTraxStep(); + services.AddScopedTraxJunction(); using var provider = services.BuildServiceProvider(); // Act - var step = provider.GetService(); + var junction = provider.GetService(); // Assert - step.Should().NotBeNull(); - step.Should().BeOfType(); + junction.Should().NotBeNull(); + junction.Should().BeOfType(); } [Test] - public void AddTransientTraxStep_Resolves_ViaInterface() + public void AddTransientTraxJunction_Resolves_ViaInterface() { // Arrange var services = new ServiceCollection(); - services.AddTransientTraxStep(); + services.AddTransientTraxJunction(); using var provider = services.BuildServiceProvider(); // Act - var step = provider.GetService(); + var junction = provider.GetService(); // Assert - step.Should().NotBeNull(); - step.Should().BeOfType(); + junction.Should().NotBeNull(); + junction.Should().BeOfType(); } [Test] - public void AddSingletonTraxStep_Resolves_ViaInterface() + public void AddSingletonTraxJunction_Resolves_ViaInterface() { // Arrange var services = new ServiceCollection(); - services.AddSingletonTraxStep(); + services.AddSingletonTraxJunction(); using var provider = services.BuildServiceProvider(); // Act - var step = provider.GetService(); + var junction = provider.GetService(); // Assert - step.Should().NotBeNull(); - step.Should().BeOfType(); + junction.Should().NotBeNull(); + junction.Should().BeOfType(); } [Test] @@ -164,26 +164,26 @@ public void AddScopedTraxRoute_NonGeneric_ServiceTrain_SetsCanonicalNameToInterf } [Test] - public void AddScopedTraxStep_DoesNotSetCanonicalName() + public void AddScopedTraxJunction_DoesNotSetCanonicalName() { var services = new ServiceCollection(); - services.AddScopedTraxStep(); + services.AddScopedTraxJunction(); using var provider = services.BuildServiceProvider(); using var scope = provider.CreateScope(); - var step = scope.ServiceProvider.GetService() as FakeStep; + var junction = scope.ServiceProvider.GetService() as FakeJunction; - step.Should().NotBeNull(); - step!.GetType().GetProperty("CanonicalName").Should().BeNull(); + junction.Should().NotBeNull(); + junction!.GetType().GetProperty("CanonicalName").Should().BeNull(); } #endregion #region Test helpers - public interface IFakeStep : IStep { } + public interface IFakeJunction : IJunction { } - public class FakeStep : Step, IFakeStep + public class FakeJunction : Junction, IFakeJunction { public override Task Run(string input) => Task.FromResult(input.Length); } diff --git a/tests/Trax.Effect.Tests.Integration/UnitTests/Extensions/ServiceExtensionsRegistryTests.cs b/tests/Trax.Effect.Tests.Integration/UnitTests/Extensions/ServiceExtensionsRegistryTests.cs index 18571a5..88f8482 100644 --- a/tests/Trax.Effect.Tests.Integration/UnitTests/Extensions/ServiceExtensionsRegistryTests.cs +++ b/tests/Trax.Effect.Tests.Integration/UnitTests/Extensions/ServiceExtensionsRegistryTests.cs @@ -1,11 +1,11 @@ using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Trax.Effect.Extensions; +using Trax.Effect.JunctionProvider.Logging.Extensions; +using Trax.Effect.JunctionProvider.Logging.Services.JunctionLoggerFactory; using Trax.Effect.Provider.Json.Extensions; using Trax.Effect.Provider.Json.Services.JsonEffectFactory; using Trax.Effect.Services.EffectRegistry; -using Trax.Effect.StepProvider.Logging.Extensions; -using Trax.Effect.StepProvider.Logging.Services.StepLoggerFactory; namespace Trax.Effect.Tests.Integration.UnitTests.Extensions; @@ -51,22 +51,22 @@ public void AddEffect_DefaultToggleable_RegistersInRegistry() } [Test] - public void AddStepEffect_DefaultToggleable_RegistersInRegistry() + public void AddJunctionEffect_DefaultToggleable_RegistersInRegistry() { // Arrange var services = new ServiceCollection(); services.AddLogging(); - // Act - AddStepLogger calls AddStepEffect() with default toggleable=true - services.AddTrax(trax => trax.AddEffects(effects => effects.AddStepLogger())); + // Act - AddJunctionLogger calls AddJunctionEffect() with default toggleable=true + services.AddTrax(trax => trax.AddEffects(effects => effects.AddJunctionLogger())); using var provider = services.BuildServiceProvider(); // Assert var registry = provider.GetRequiredService(); var all = registry.GetAll(); - all.Should().ContainKey(typeof(StepLoggerFactory)); - all[typeof(StepLoggerFactory)].Should().BeTrue(); + all.Should().ContainKey(typeof(JunctionLoggerFactory)); + all[typeof(JunctionLoggerFactory)].Should().BeTrue(); } [Test] @@ -110,7 +110,7 @@ public void AddTrax_MultipleEffects_AllRegistered() services.AddLogging(); // Act - services.AddTrax(trax => trax.AddEffects(effects => effects.AddJson().AddStepLogger())); + services.AddTrax(trax => trax.AddEffects(effects => effects.AddJson().AddJunctionLogger())); using var provider = services.BuildServiceProvider(); // Assert @@ -119,6 +119,6 @@ public void AddTrax_MultipleEffects_AllRegistered() all.Should().HaveCount(2); all.Should().ContainKey(typeof(JsonEffectProviderFactory)); - all.Should().ContainKey(typeof(StepLoggerFactory)); + all.Should().ContainKey(typeof(JunctionLoggerFactory)); } } diff --git a/tests/Trax.Effect.Tests.Integration/UnitTests/Services/EffectRegistryTests.cs b/tests/Trax.Effect.Tests.Integration/UnitTests/Services/EffectRegistryTests.cs index 7d86415..430eb17 100644 --- a/tests/Trax.Effect.Tests.Integration/UnitTests/Services/EffectRegistryTests.cs +++ b/tests/Trax.Effect.Tests.Integration/UnitTests/Services/EffectRegistryTests.cs @@ -1,7 +1,7 @@ using FluentAssertions; using Trax.Effect.Services.EffectProviderFactory; using Trax.Effect.Services.EffectRegistry; -using Trax.Effect.Services.StepEffectProviderFactory; +using Trax.Effect.Services.JunctionEffectProviderFactory; namespace Trax.Effect.Tests.Integration.UnitTests.Services; diff --git a/tests/Trax.Effect.Tests.Integration/UnitTests/Services/EffectRunnerRegistryTests.cs b/tests/Trax.Effect.Tests.Integration/UnitTests/Services/EffectRunnerRegistryTests.cs index a318476..25891bb 100644 --- a/tests/Trax.Effect.Tests.Integration/UnitTests/Services/EffectRunnerRegistryTests.cs +++ b/tests/Trax.Effect.Tests.Integration/UnitTests/Services/EffectRunnerRegistryTests.cs @@ -1,14 +1,14 @@ using FluentAssertions; using Trax.Effect.Models; +using Trax.Effect.Services.EffectJunction; using Trax.Effect.Services.EffectProvider; using Trax.Effect.Services.EffectProviderFactory; using Trax.Effect.Services.EffectRegistry; using Trax.Effect.Services.EffectRunner; -using Trax.Effect.Services.EffectStep; +using Trax.Effect.Services.JunctionEffectProvider; +using Trax.Effect.Services.JunctionEffectProviderFactory; +using Trax.Effect.Services.JunctionEffectRunner; using Trax.Effect.Services.ServiceTrain; -using Trax.Effect.Services.StepEffectProvider; -using Trax.Effect.Services.StepEffectProviderFactory; -using Trax.Effect.Services.StepEffectRunner; namespace Trax.Effect.Tests.Integration.UnitTests.Services; @@ -173,66 +173,66 @@ public void EffectRunner_Dispose_HandlesProviderDisposalFailure() #endregion - #region StepEffectRunner + #region JunctionEffectRunner [Test] - public void StepEffectRunner_DisabledFactory_SkipsCreateCall() + public void JunctionEffectRunner_DisabledFactory_SkipsCreateCall() { // Arrange var registry = new EffectRegistry(); - var factory = new DisabledStepEffectFactory(); - registry.Register(typeof(DisabledStepEffectFactory), enabled: false); + var factory = new DisabledJunctionEffectFactory(); + registry.Register(typeof(DisabledJunctionEffectFactory), enabled: false); // Act - using var runner = new StepEffectRunner([factory], registry); + using var runner = new JunctionEffectRunner([factory], registry); // Assert factory.CreateCalled.Should().BeFalse(); } [Test] - public void StepEffectRunner_EnabledFactory_CallsCreate() + public void JunctionEffectRunner_EnabledFactory_CallsCreate() { // Arrange var registry = new EffectRegistry(); - var factory = new EnabledStepEffectFactory(); - registry.Register(typeof(EnabledStepEffectFactory), enabled: true); + var factory = new EnabledJunctionEffectFactory(); + registry.Register(typeof(EnabledJunctionEffectFactory), enabled: true); // Act - using var runner = new StepEffectRunner([factory], registry); + using var runner = new JunctionEffectRunner([factory], registry); // Assert factory.CreateCalled.Should().BeTrue(); } [Test] - public void StepEffectRunner_UntrackedFactory_CallsCreate() + public void JunctionEffectRunner_UntrackedFactory_CallsCreate() { // Arrange - factory type not registered in registry (infrastructure effect) var registry = new EffectRegistry(); - var factory = new EnabledStepEffectFactory(); + var factory = new EnabledJunctionEffectFactory(); // Intentionally NOT registering the factory type // Act - using var runner = new StepEffectRunner([factory], registry); + using var runner = new JunctionEffectRunner([factory], registry); // Assert factory.CreateCalled.Should().BeTrue(); } [Test] - public void StepEffectRunner_MixOfEnabledAndDisabled_OnlyCreatesEnabled() + public void JunctionEffectRunner_MixOfEnabledAndDisabled_OnlyCreatesEnabled() { // Arrange - use concrete stub types so GetType() returns distinct types var registry = new EffectRegistry(); - var enabledFactory = new EnabledStepEffectFactory(); - var disabledFactory = new DisabledStepEffectFactory(); + var enabledFactory = new EnabledJunctionEffectFactory(); + var disabledFactory = new DisabledJunctionEffectFactory(); - registry.Register(typeof(EnabledStepEffectFactory), enabled: true); - registry.Register(typeof(DisabledStepEffectFactory), enabled: false); + registry.Register(typeof(EnabledJunctionEffectFactory), enabled: true); + registry.Register(typeof(DisabledJunctionEffectFactory), enabled: false); // Act - using var runner = new StepEffectRunner([enabledFactory, disabledFactory], registry); + using var runner = new JunctionEffectRunner([enabledFactory, disabledFactory], registry); // Assert enabledFactory.CreateCalled.Should().BeTrue(); @@ -240,18 +240,18 @@ public void StepEffectRunner_MixOfEnabledAndDisabled_OnlyCreatesEnabled() } [Test] - public void StepEffectRunner_NonToggleableFactory_CannotBeDisabled() + public void JunctionEffectRunner_NonToggleableFactory_CannotBeDisabled() { // Arrange - register as non-toggleable, then try to disable var registry = new EffectRegistry(); - var factory = new EnabledStepEffectFactory(); - registry.Register(typeof(EnabledStepEffectFactory), enabled: true, toggleable: false); + var factory = new EnabledJunctionEffectFactory(); + registry.Register(typeof(EnabledJunctionEffectFactory), enabled: true, toggleable: false); // Attempt to disable should be a no-op - registry.Disable(typeof(EnabledStepEffectFactory)); + registry.Disable(typeof(EnabledJunctionEffectFactory)); // Act - using var runner = new StepEffectRunner([factory], registry); + using var runner = new JunctionEffectRunner([factory], registry); // Assert - factory should still run because it can't be disabled factory.CreateCalled.Should().BeTrue(); @@ -259,18 +259,18 @@ public void StepEffectRunner_NonToggleableFactory_CannotBeDisabled() #endregion - #region StepEffectRunner Behavior + #region JunctionEffectRunner Behavior [Test] - public void StepEffectRunner_Dispose_HandlesProviderDisposalFailure() + public void JunctionEffectRunner_Dispose_HandlesProviderDisposalFailure() { var registry = new EffectRegistry(); - var throwingFactory = new ThrowingDisposeStepEffectFactory(); - var normalFactory = new EnabledStepEffectFactory(); - registry.Register(typeof(ThrowingDisposeStepEffectFactory), enabled: true); - registry.Register(typeof(EnabledStepEffectFactory), enabled: true); + var throwingFactory = new ThrowingDisposeJunctionEffectFactory(); + var normalFactory = new EnabledJunctionEffectFactory(); + registry.Register(typeof(ThrowingDisposeJunctionEffectFactory), enabled: true); + registry.Register(typeof(EnabledJunctionEffectFactory), enabled: true); - var runner = new StepEffectRunner([throwingFactory, normalFactory], registry); + var runner = new JunctionEffectRunner([throwingFactory, normalFactory], registry); var act = () => runner.Dispose(); act.Should().NotThrow(); @@ -315,16 +315,16 @@ public IEffectProvider Create() } } - private class StubStepEffectProvider : IStepEffectProvider + private class StubJunctionEffectProvider : IJunctionEffectProvider { - public Task BeforeStepExecution( - EffectStep effectStep, + public Task BeforeJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) => Task.CompletedTask; - public Task AfterStepExecution( - EffectStep effectStep, + public Task AfterJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) => Task.CompletedTask; @@ -332,25 +332,25 @@ CancellationToken cancellationToken public void Dispose() { } } - private class EnabledStepEffectFactory : IStepEffectProviderFactory + private class EnabledJunctionEffectFactory : IJunctionEffectProviderFactory { public bool CreateCalled { get; private set; } - public IStepEffectProvider Create() + public IJunctionEffectProvider Create() { CreateCalled = true; - return new StubStepEffectProvider(); + return new StubJunctionEffectProvider(); } } - private class DisabledStepEffectFactory : IStepEffectProviderFactory + private class DisabledJunctionEffectFactory : IJunctionEffectProviderFactory { public bool CreateCalled { get; private set; } - public IStepEffectProvider Create() + public IJunctionEffectProvider Create() { CreateCalled = true; - return new StubStepEffectProvider(); + return new StubJunctionEffectProvider(); } } @@ -430,18 +430,18 @@ private class ThrowingDisposeEffectFactory : IEffectProviderFactory public IEffectProvider Create() => Provider; } - private class ThrowingDisposeStepEffectProvider : IStepEffectProvider + private class ThrowingDisposeJunctionEffectProvider : IJunctionEffectProvider { public bool DisposeCalled { get; private set; } - public Task BeforeStepExecution( - EffectStep effectStep, + public Task BeforeJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) => Task.CompletedTask; - public Task AfterStepExecution( - EffectStep effectStep, + public Task AfterJunctionExecution( + EffectJunction effectJunction, ServiceTrain serviceTrain, CancellationToken cancellationToken ) => Task.CompletedTask; @@ -453,11 +453,11 @@ public void Dispose() } } - private class ThrowingDisposeStepEffectFactory : IStepEffectProviderFactory + private class ThrowingDisposeJunctionEffectFactory : IJunctionEffectProviderFactory { - public ThrowingDisposeStepEffectProvider Provider { get; } = new(); + public ThrowingDisposeJunctionEffectProvider Provider { get; } = new(); - public IStepEffectProvider Create() => Provider; + public IJunctionEffectProvider Create() => Provider; } #endregion diff --git a/tests/Trax.Effect.Tests.Integration/UnitTests/Services/StepProgressProviderTests.cs b/tests/Trax.Effect.Tests.Integration/UnitTests/Services/JunctionProgressProviderTests.cs similarity index 52% rename from tests/Trax.Effect.Tests.Integration/UnitTests/Services/StepProgressProviderTests.cs rename to tests/Trax.Effect.Tests.Integration/UnitTests/Services/JunctionProgressProviderTests.cs index 5a78c84..cba6a28 100644 --- a/tests/Trax.Effect.Tests.Integration/UnitTests/Services/StepProgressProviderTests.cs +++ b/tests/Trax.Effect.Tests.Integration/UnitTests/Services/JunctionProgressProviderTests.cs @@ -1,32 +1,32 @@ using System.Reflection; using FluentAssertions; using LanguageExt; +using Trax.Effect.JunctionProvider.Progress.Services.JunctionProgressProvider; using Trax.Effect.Models; +using Trax.Effect.Models.JunctionMetadata; +using Trax.Effect.Models.JunctionMetadata.DTOs; using Trax.Effect.Models.Metadata; using Trax.Effect.Models.Metadata.DTOs; -using Trax.Effect.Models.StepMetadata; -using Trax.Effect.Models.StepMetadata.DTOs; +using Trax.Effect.Services.EffectJunction; using Trax.Effect.Services.EffectRunner; -using Trax.Effect.Services.EffectStep; using Trax.Effect.Services.ServiceTrain; -using Trax.Effect.StepProvider.Progress.Services.StepProgressProvider; namespace Trax.Effect.Tests.Integration.UnitTests.Services; /// -/// Unit tests for , the step effect provider -/// that writes currently-running step name and timestamp to train metadata. +/// Unit tests for , the junction effect provider +/// that writes currently-running junction name and timestamp to train metadata. /// [TestFixture] -public class StepProgressProviderTests +public class JunctionProgressProviderTests { - private StepProgressProvider _provider; + private JunctionProgressProvider _provider; private FakeEffectRunner _fakeEffectRunner; [SetUp] public void SetUp() { - _provider = new StepProgressProvider(); + _provider = new JunctionProgressProvider(); _fakeEffectRunner = new FakeEffectRunner(); } @@ -37,101 +37,101 @@ public void TearDown() _fakeEffectRunner.Dispose(); } - #region BeforeStepExecution Tests + #region BeforeJunctionExecution Tests [Test] - public async Task BeforeStepExecution_SetsCurrentlyRunningStep() + public async Task BeforeJunctionExecution_SetsCurrentlyRunningJunction() { // Arrange - var (train, step) = CreateTestTrainAndStep("ProcessDataStep"); + var (train, junction) = CreateTestTrainAndJunction("ProcessDataJunction"); // Act - await _provider.BeforeStepExecution(step, train, CancellationToken.None); + await _provider.BeforeJunctionExecution(junction, train, CancellationToken.None); // Assert - train.Metadata!.CurrentlyRunningStep.Should().Be("ProcessDataStep"); + train.Metadata!.CurrentlyRunningJunction.Should().Be("ProcessDataJunction"); } [Test] - public async Task BeforeStepExecution_SetsStepStartedAt() + public async Task BeforeJunctionExecution_SetsJunctionStartedAt() { // Arrange - var (train, step) = CreateTestTrainAndStep("ProcessDataStep"); + var (train, junction) = CreateTestTrainAndJunction("ProcessDataJunction"); var before = DateTime.UtcNow; // Act - await _provider.BeforeStepExecution(step, train, CancellationToken.None); + await _provider.BeforeJunctionExecution(junction, train, CancellationToken.None); // Assert - train.Metadata!.StepStartedAt.Should().NotBeNull(); - train.Metadata!.StepStartedAt.Should().BeOnOrAfter(before); - train.Metadata!.StepStartedAt.Should().BeOnOrBefore(DateTime.UtcNow); + train.Metadata!.JunctionStartedAt.Should().NotBeNull(); + train.Metadata!.JunctionStartedAt.Should().BeOnOrAfter(before); + train.Metadata!.JunctionStartedAt.Should().BeOnOrBefore(DateTime.UtcNow); } [Test] - public async Task BeforeStepExecution_CallsEffectRunnerUpdate() + public async Task BeforeJunctionExecution_CallsEffectRunnerUpdate() { // Arrange - var (train, step) = CreateTestTrainAndStep("ProcessDataStep"); + var (train, junction) = CreateTestTrainAndJunction("ProcessDataJunction"); // Act - await _provider.BeforeStepExecution(step, train, CancellationToken.None); + await _provider.BeforeJunctionExecution(junction, train, CancellationToken.None); // Assert _fakeEffectRunner.UpdateCallCount.Should().Be(1); } [Test] - public async Task BeforeStepExecution_CallsEffectRunnerSaveChanges() + public async Task BeforeJunctionExecution_CallsEffectRunnerSaveChanges() { // Arrange - var (train, step) = CreateTestTrainAndStep("ProcessDataStep"); + var (train, junction) = CreateTestTrainAndJunction("ProcessDataJunction"); // Act - await _provider.BeforeStepExecution(step, train, CancellationToken.None); + await _provider.BeforeJunctionExecution(junction, train, CancellationToken.None); // Assert _fakeEffectRunner.SaveChangesCallCount.Should().Be(1); } [Test] - public async Task BeforeStepExecution_NullMetadata_ReturnsWithoutError() + public async Task BeforeJunctionExecution_NullMetadata_ReturnsWithoutError() { // Arrange — train with null metadata (no reflection call) var train = new TestTrain(); train.EffectRunner = _fakeEffectRunner; - var step = CreateTestStep("SomeStep"); + var junction = CreateTestJunction("SomeJunction"); // Act & Assert - var act = () => _provider.BeforeStepExecution(step, train, CancellationToken.None); + var act = () => _provider.BeforeJunctionExecution(junction, train, CancellationToken.None); await act.Should().NotThrowAsync(); _fakeEffectRunner.UpdateCallCount.Should().Be(0); } [Test] - public async Task BeforeStepExecution_NullEffectRunner_ReturnsWithoutError() + public async Task BeforeJunctionExecution_NullEffectRunner_ReturnsWithoutError() { // Arrange — train with metadata but no EffectRunner var train = new TestTrain(); SetInternalProperty(train, "Metadata", CreateMetadata()); // EffectRunner left as null - var step = CreateTestStep("SomeStep"); + var junction = CreateTestJunction("SomeJunction"); // Act & Assert - var act = () => _provider.BeforeStepExecution(step, train, CancellationToken.None); + var act = () => _provider.BeforeJunctionExecution(junction, train, CancellationToken.None); await act.Should().NotThrowAsync(); } [Test] - public async Task BeforeStepExecution_PassesCancellationTokenToSaveChanges() + public async Task BeforeJunctionExecution_PassesCancellationTokenToSaveChanges() { // Arrange - var (train, step) = CreateTestTrainAndStep("ProcessDataStep"); + var (train, junction) = CreateTestTrainAndJunction("ProcessDataJunction"); using var cts = new CancellationTokenSource(); // Act - await _provider.BeforeStepExecution(step, train, cts.Token); + await _provider.BeforeJunctionExecution(junction, train, cts.Token); // Assert _fakeEffectRunner.SaveChangesCallCount.Should().Be(1); @@ -140,46 +140,46 @@ public async Task BeforeStepExecution_PassesCancellationTokenToSaveChanges() #endregion - #region AfterStepExecution Tests + #region AfterJunctionExecution Tests [Test] - public async Task AfterStepExecution_ClearsCurrentlyRunningStep() + public async Task AfterJunctionExecution_ClearsCurrentlyRunningJunction() { // Arrange - var (train, step) = CreateTestTrainAndStep("ProcessDataStep"); - train.Metadata!.CurrentlyRunningStep = "ProcessDataStep"; - train.Metadata!.StepStartedAt = DateTime.UtcNow; + var (train, junction) = CreateTestTrainAndJunction("ProcessDataJunction"); + train.Metadata!.CurrentlyRunningJunction = "ProcessDataJunction"; + train.Metadata!.JunctionStartedAt = DateTime.UtcNow; // Act - await _provider.AfterStepExecution(step, train, CancellationToken.None); + await _provider.AfterJunctionExecution(junction, train, CancellationToken.None); // Assert - train.Metadata!.CurrentlyRunningStep.Should().BeNull(); + train.Metadata!.CurrentlyRunningJunction.Should().BeNull(); } [Test] - public async Task AfterStepExecution_ClearsStepStartedAt() + public async Task AfterJunctionExecution_ClearsJunctionStartedAt() { // Arrange - var (train, step) = CreateTestTrainAndStep("ProcessDataStep"); - train.Metadata!.CurrentlyRunningStep = "ProcessDataStep"; - train.Metadata!.StepStartedAt = DateTime.UtcNow; + var (train, junction) = CreateTestTrainAndJunction("ProcessDataJunction"); + train.Metadata!.CurrentlyRunningJunction = "ProcessDataJunction"; + train.Metadata!.JunctionStartedAt = DateTime.UtcNow; // Act - await _provider.AfterStepExecution(step, train, CancellationToken.None); + await _provider.AfterJunctionExecution(junction, train, CancellationToken.None); // Assert - train.Metadata!.StepStartedAt.Should().BeNull(); + train.Metadata!.JunctionStartedAt.Should().BeNull(); } [Test] - public async Task AfterStepExecution_CallsEffectRunnerUpdateAndSaveChanges() + public async Task AfterJunctionExecution_CallsEffectRunnerUpdateAndSaveChanges() { // Arrange - var (train, step) = CreateTestTrainAndStep("ProcessDataStep"); + var (train, junction) = CreateTestTrainAndJunction("ProcessDataJunction"); // Act - await _provider.AfterStepExecution(step, train, CancellationToken.None); + await _provider.AfterJunctionExecution(junction, train, CancellationToken.None); // Assert _fakeEffectRunner.UpdateCallCount.Should().Be(1); @@ -187,15 +187,15 @@ public async Task AfterStepExecution_CallsEffectRunnerUpdateAndSaveChanges() } [Test] - public async Task AfterStepExecution_NullMetadata_ReturnsWithoutError() + public async Task AfterJunctionExecution_NullMetadata_ReturnsWithoutError() { // Arrange — train with null metadata (no reflection call) var train = new TestTrain(); train.EffectRunner = _fakeEffectRunner; - var step = CreateTestStep("SomeStep"); + var junction = CreateTestJunction("SomeJunction"); // Act & Assert - var act = () => _provider.AfterStepExecution(step, train, CancellationToken.None); + var act = () => _provider.AfterJunctionExecution(junction, train, CancellationToken.None); await act.Should().NotThrowAsync(); _fakeEffectRunner.UpdateCallCount.Should().Be(0); @@ -206,49 +206,49 @@ public async Task AfterStepExecution_NullMetadata_ReturnsWithoutError() #region Full Lifecycle Tests [Test] - public async Task FullLifecycle_BeforeAndAfter_SetsAndClearsStepProgress() + public async Task FullLifecycle_BeforeAndAfter_SetsAndClearsJunctionProgress() { // Arrange - var (train, step) = CreateTestTrainAndStep("FetchDataStep"); + var (train, junction) = CreateTestTrainAndJunction("FetchDataJunction"); // Act — Before - await _provider.BeforeStepExecution(step, train, CancellationToken.None); + await _provider.BeforeJunctionExecution(junction, train, CancellationToken.None); // Assert — progress is set - train.Metadata!.CurrentlyRunningStep.Should().Be("FetchDataStep"); - train.Metadata!.StepStartedAt.Should().NotBeNull(); + train.Metadata!.CurrentlyRunningJunction.Should().Be("FetchDataJunction"); + train.Metadata!.JunctionStartedAt.Should().NotBeNull(); // Act — After - await _provider.AfterStepExecution(step, train, CancellationToken.None); + await _provider.AfterJunctionExecution(junction, train, CancellationToken.None); // Assert — progress is cleared - train.Metadata!.CurrentlyRunningStep.Should().BeNull(); - train.Metadata!.StepStartedAt.Should().BeNull(); + train.Metadata!.CurrentlyRunningJunction.Should().BeNull(); + train.Metadata!.JunctionStartedAt.Should().BeNull(); } [Test] - public async Task FullLifecycle_MultipleSteps_TracksEachStepSeparately() + public async Task FullLifecycle_MultipleJunctions_TracksEachJunctionSeparately() { // Arrange - var (train, _) = CreateTestTrainAndStep("Unused"); - var step1 = CreateTestStep("Step1"); - var step2 = CreateTestStep("Step2"); + var (train, _) = CreateTestTrainAndJunction("Unused"); + var junction1 = CreateTestJunction("Junction1"); + var junction2 = CreateTestJunction("Junction2"); // Step 1 lifecycle - await _provider.BeforeStepExecution(step1, train, CancellationToken.None); - train.Metadata!.CurrentlyRunningStep.Should().Be("Step1"); + await _provider.BeforeJunctionExecution(junction1, train, CancellationToken.None); + train.Metadata!.CurrentlyRunningJunction.Should().Be("Junction1"); - await _provider.AfterStepExecution(step1, train, CancellationToken.None); - train.Metadata!.CurrentlyRunningStep.Should().BeNull(); + await _provider.AfterJunctionExecution(junction1, train, CancellationToken.None); + train.Metadata!.CurrentlyRunningJunction.Should().BeNull(); // Step 2 lifecycle - await _provider.BeforeStepExecution(step2, train, CancellationToken.None); - train.Metadata!.CurrentlyRunningStep.Should().Be("Step2"); + await _provider.BeforeJunctionExecution(junction2, train, CancellationToken.None); + train.Metadata!.CurrentlyRunningJunction.Should().Be("Junction2"); - await _provider.AfterStepExecution(step2, train, CancellationToken.None); - train.Metadata!.CurrentlyRunningStep.Should().BeNull(); + await _provider.AfterJunctionExecution(junction2, train, CancellationToken.None); + train.Metadata!.CurrentlyRunningJunction.Should().BeNull(); - // Verify 4 updates (before+after for each step) and 4 saves + // Verify 4 updates (before+after for each junction) and 4 saves _fakeEffectRunner.UpdateCallCount.Should().Be(4); _fakeEffectRunner.SaveChangesCallCount.Should().Be(4); } @@ -279,11 +279,11 @@ public void Dispose_CanBeCalledMultipleTimes() #region Test Helpers - private (TestTrain train, TestStep step) CreateTestTrainAndStep(string stepName) + private (TestTrain train, TestJunction junction) CreateTestTrainAndJunction(string junctionName) { var train = CreateTestTrain(); - var step = CreateTestStep(stepName); - return (train, step); + var junction = CreateTestJunction(junctionName); + return (train, junction); } private TestTrain CreateTestTrain(Metadata? metadata = null, IEffectRunner? effectRunner = null) @@ -308,11 +308,11 @@ private TestTrain CreateTestTrain(bool withNullMetadata) return train; } - private TestStep CreateTestStep(string name) + private TestJunction CreateTestJunction(string name) { - var step = new TestStep(); - SetStepMetadata(step, name); - return step; + var junction = new TestJunction(); + SetJunctionMetadata(junction, name); + return junction; } private static Metadata CreateMetadata() => @@ -335,14 +335,14 @@ private static void SetInternalProperty(T target, string propertyName, object } /// - /// Sets the StepMetadata on an EffectStep via reflection (private setter). + /// Sets the JunctionMetadata on an EffectJunction via reflection (private setter). /// - private static void SetStepMetadata(TestStep step, string name) + private static void SetJunctionMetadata(TestJunction junction, string name) { var parentMetadata = CreateMetadata(); - var stepMeta = StepMetadata.Create( - new CreateStepMetadata + var junctionMeta = JunctionMetadata.Create( + new CreateJunctionMetadata { Name = name, ExternalId = Guid.NewGuid().ToString("N"), @@ -353,11 +353,11 @@ private static void SetStepMetadata(TestStep step, string name) parentMetadata ); - var prop = typeof(EffectStep).GetProperty( + var prop = typeof(EffectJunction).GetProperty( "Metadata", BindingFlags.Public | BindingFlags.Instance ); - prop?.SetValue(step, stepMeta); + prop?.SetValue(junction, junctionMeta); } /// @@ -370,9 +370,9 @@ protected override Task> RunInternal(string input) => } /// - /// Concrete test double for EffectStep. + /// Concrete test double for EffectJunction. /// - private class TestStep : EffectStep + private class TestJunction : EffectJunction { public override Task Run(string input) => Task.FromResult(input); } diff --git a/tests/Trax.Effect.Tests.Json.Integration/Fixtures/TestSetup.cs b/tests/Trax.Effect.Tests.Json.Integration/Fixtures/TestSetup.cs index f6d3f8a..ddfb500 100644 --- a/tests/Trax.Effect.Tests.Json.Integration/Fixtures/TestSetup.cs +++ b/tests/Trax.Effect.Tests.Json.Integration/Fixtures/TestSetup.cs @@ -1,8 +1,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Trax.Effect.Extensions; +using Trax.Effect.JunctionProvider.Logging.Extensions; using Trax.Effect.Provider.Json.Extensions; -using Trax.Effect.StepProvider.Logging.Extensions; using Trax.Effect.Tests.ArrayLogger.Services.ArrayLoggingProvider; namespace Trax.Effect.Tests.Json.Integration.Fixtures; @@ -32,7 +32,7 @@ public async Task RunBeforeAnyTests() effects .SetEffectLogLevel(LogLevel.Information) .AddJson() - .AddStepLogger(serializeStepData: true) + .AddJunctionLogger(serializeJunctionData: true) ) ); diff --git a/tests/Trax.Effect.Tests.Json.Integration/IntegrationTests/JsonEffectProviderTests.cs b/tests/Trax.Effect.Tests.Json.Integration/IntegrationTests/JsonEffectProviderTests.cs index e1017b2..b71a916 100644 --- a/tests/Trax.Effect.Tests.Json.Integration/IntegrationTests/JsonEffectProviderTests.cs +++ b/tests/Trax.Effect.Tests.Json.Integration/IntegrationTests/JsonEffectProviderTests.cs @@ -30,7 +30,7 @@ public async Task TestJsonEffect() train.Metadata.Name.Should().Be(typeof(ITestTrain).FullName); train.Metadata.FailureException.Should().BeNullOrEmpty(); train.Metadata.FailureReason.Should().BeNullOrEmpty(); - train.Metadata.FailureStep.Should().BeNullOrEmpty(); + train.Metadata.FailureJunction.Should().BeNullOrEmpty(); train.Metadata.TrainState.Should().Be(TrainState.Completed); arrayProvider.Loggers.Should().NotBeNullOrEmpty(); arrayProvider.Loggers.Should().HaveCount(6); diff --git a/tests/Trax.Effect.Tests.Json.Integration/IntegrationTests/JsonEffectToggleTests.cs b/tests/Trax.Effect.Tests.Json.Integration/IntegrationTests/JsonEffectToggleTests.cs index 519516c..aeec4e2 100644 --- a/tests/Trax.Effect.Tests.Json.Integration/IntegrationTests/JsonEffectToggleTests.cs +++ b/tests/Trax.Effect.Tests.Json.Integration/IntegrationTests/JsonEffectToggleTests.cs @@ -4,11 +4,11 @@ using Microsoft.Extensions.Logging; using Trax.Effect.Enums; using Trax.Effect.Extensions; +using Trax.Effect.JunctionProvider.Logging.Extensions; using Trax.Effect.Provider.Json.Extensions; using Trax.Effect.Provider.Json.Services.JsonEffectFactory; using Trax.Effect.Services.EffectRegistry; using Trax.Effect.Services.ServiceTrain; -using Trax.Effect.StepProvider.Logging.Extensions; using Trax.Effect.Tests.ArrayLogger.Services.ArrayLoggingProvider; namespace Trax.Effect.Tests.Json.Integration.IntegrationTests; @@ -36,7 +36,7 @@ public void RunBeforeAnyTests() effects .SetEffectLogLevel(LogLevel.Information) .AddJson() - .AddStepLogger(serializeStepData: true) + .AddJunctionLogger(serializeJunctionData: true) ) ) .AddTransientTraxRoute(); diff --git a/tests/Trax.Effect.Tests.Json.Integration/Trax.Effect.Tests.Json.Integration.csproj b/tests/Trax.Effect.Tests.Json.Integration/Trax.Effect.Tests.Json.Integration.csproj index 0d1f8e5..e5d7682 100644 --- a/tests/Trax.Effect.Tests.Json.Integration/Trax.Effect.Tests.Json.Integration.csproj +++ b/tests/Trax.Effect.Tests.Json.Integration/Trax.Effect.Tests.Json.Integration.csproj @@ -28,6 +28,6 @@ - +