JasperFx / jasper

Next generation application development framework for .Net
http://jasperfx.github.io/
MIT License
417 stars 55 forks source link

Quick configuration policy to mark all endpoints as being durable in one line of code #731

Open jeremydmiller opened 2 years ago

jeremydmiller commented 2 years ago

Some notes:

Introduce back some sort of EndpointCollection as a child of JasperRuntime. That would hold the policies.

public interface IEndpointPolicy
{
    void Apply(Endpoint endpoint, IJasperRuntime runtime);
}

internal class LambdaEndpointPolicy<T> : IEndpointPolicy where T : Endpoint
{
    private readonly Action<T, IJasperRuntime> _configure;

    public LambdaEndpointPolicy(Action<T, IJasperRuntime> configure)
    {
        _configure = configure;
    }

    public void Apply(Endpoint endpoint, IJasperRuntime runtime)
    {
        if (endpoint is T e) _configure(e, runtime);
    }
}