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

Ship InMemoryConfigProvider #1732

Merged
merged 2 commits into from
May 23, 2022
Merged

Ship InMemoryConfigProvider #1732

merged 2 commits into from
May 23, 2022

Conversation

Tratcher
Copy link
Member

Fixes #1713

This ships InMemoryConfigProvider, removes redundant copies, and proposes an update pattern.

@Tratcher Tratcher added this to the YARP 2.0.0 milestone May 23, 2022
@Tratcher Tratcher requested a review from MihaZupan as a code owner May 23, 2022 19:02
@Tratcher Tratcher self-assigned this May 23, 2022
@Tratcher Tratcher requested a review from greenEkatherine May 23, 2022 19:02
samples/ReverseProxy.Code.Sample/Startup.cs Outdated Show resolved Hide resolved
Comment on lines +16 to +17
builder.Services.AddSingleton(new InMemoryConfigProvider(routes, clusters));
builder.Services.AddSingleton<IProxyConfigProvider>(s => s.GetRequiredService<InMemoryConfigProvider>());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
builder.Services.AddSingleton(new InMemoryConfigProvider(routes, clusters));
builder.Services.AddSingleton<IProxyConfigProvider>(s => s.GetRequiredService<InMemoryConfigProvider>());
builder.Services.AddSingleton<IProxyConfigProvider>(new InMemoryConfigProvider(routes, clusters));

Isn't this equivalent?

Copy link
Member Author

@Tratcher Tratcher May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InMemoryConfigProvider is intentionally registered independently so you can resolve InMemoryConfigProvider and call Update without downcasting.

src/ReverseProxy/Configuration/InMemoryConfigProvider.cs Outdated Show resolved Hide resolved
@Tratcher Tratcher enabled auto-merge (squash) May 23, 2022 20:23
@Tratcher Tratcher merged commit 28a50f1 into main May 23, 2022
@Tratcher Tratcher deleted the tratcher/inmem branch May 23, 2022 20:26
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

Successfully merging this pull request may close these issues.

Ship InMemoryConfigProvider
3 participants