Skip to content

Behavior Interface Proliferation: Consolidate module customization patterns #1866

@thomhurst

Description

@thomhurst

Problem

Module customization is scattered across 6+ marker interfaces (ISkippable, IRetryable, ITimeoutable, IIgnoreFailures, IHookable, IAlwaysRun) instead of a unified configuration approach. This creates:

  • Complexity: Each behavior requires implementation
  • Consistency Issues: Each behavior has different patterns for configuration
  • Discoverability: Hard to find all available module behaviors
  • Maintenance: Adding new behaviors requires new interface

Current Design

public class MyModule : Module<string>, ISkippable, IRetryable<string>, ITimeoutable, IIgnoreFailures
{
    public bool ShouldSkip(IPipelineContext context) => ...
    public IAsyncPolicy<ModuleResult<string?>> GetRetryPolicy() => ...
    public TimeSpan? Timeout => ...
    public async Task OnBeforeExecuteAsync(IPipelineContext context) => ...
}

Proposed Solution

Consolidate into a single builder or configuration interface:

public class MyModule : Module<string>
{
    protected override ModuleConfiguration Configure()
    {
        return ModuleConfiguration.Create()
            .WithSkipCondition(ctx => ...)
            .WithRetryPolicy(policy)
            .WithTimeout(TimeSpan.FromSeconds(30))
            .WithErrorHandling(ErrorHandlingStrategy.IgnoreFailures)
            .WithHook(HookType.Before, OnBeforeAsync)
            .WithAlwaysRun();
    }
}

Benefits

  • Single, consistent configuration point
  • Fluent API is more discoverable
  • Easier to validate configurations
  • Adding new behaviors doesn't require new interfaces
  • Better IDE autocomplete experience

Priority: HIGH - Breaking change, high impact on API design

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions