Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASP.NET Core 6 - RinOptions not honored #78

Open
paralaxsd opened this issue Mar 5, 2024 · 1 comment
Open

ASP.NET Core 6 - RinOptions not honored #78

paralaxsd opened this issue Mar 5, 2024 · 1 comment

Comments

@paralaxsd
Copy link

paralaxsd commented Mar 5, 2024

Hi,

I'm using Rin with an ASP.NET Core 6.0 web API and I found that the options given to Rin via the

public static IRinBuilder AddRin(this IServiceCollection services, Action<RinOptions>? configure = null)

extension method are disregarded. (In my concrete case retention max stays at 100 elements.)

I had a look into the code and it seems to me this is due to the way aforementioned extension method is written: it registers the RinOptions instance previously given to calling end users via lambda expression and registers it as a singleton instance.

Later, services such as InMemoryRecordStorage consume the option via DI but wrapped by IOption.

In order to use options this way however, the RinOptions instance should be registered as an explicit option and since it isn't a default option instance is handed over to the consuming service.

As a workaround, I can set the max number of retained records after calling AddRin() without parameters:
services.AddOptions<RinOptions>().Configure(o => o.RequestRecorder.RetentionMaxRequests = 6);

I guess it should probably suffice to adapt the RinOptions registration logic in AddRin (set the case the all other services also consume the instance via IOption<T>).

@paralaxsd
Copy link
Author

I just tested recorder excludes and these actually work out of the box, so RinOptions usage varies across the code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant