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

[Refactoring] Introduce RequestContext to easily pass new parameters to downstream methods #2407

Open
opeco17 opened this issue Apr 22, 2024 · 0 comments · May be fixed by #2408
Open

[Refactoring] Introduce RequestContext to easily pass new parameters to downstream methods #2407

opeco17 opened this issue Apr 22, 2024 · 0 comments · May be fixed by #2408

Comments

@opeco17
Copy link

opeco17 commented Apr 22, 2024

Is your feature request related to a problem? Please describe.
In the current implementation, it's necessary to change a bunch of method signatures when we introduce new HTTP parameters and pass them to downstream methods.

Let's say you introduce the new parameter forceRefresh like #2402.
In this case, you need to change the signature of EnvironmentRepository and SearchPathLocator and modify a lot of classes that implement those interfaces.

Before introducing forceRefresh

public interface EnvironmentRepository {
	Environment findOne(String application, String profile, String label);
        Environment findOne(String application, String profile, String label, boolean includeOrigin);
}

public interface SearchPathLocator {
	Locations getLocations(String application, String profile, String label);
}

After introducing forceRefresh

public interface EnvironmentRepository {
	Environment findOne(String application, String profile, String label);
        Environment findOne(String application, String profile, String label, boolean includeOrigin);
        Environment findOne(String application, String profile, String label, boolean includeOrigin, boolean forceRefresh);
}

public interface SearchPathLocator {
	Locations getLocations(String application, String profile, String label);
        Locations getLocations(String application, String profile, String label, boolean forceRefresh);
}

Describe the solution you'd like
Introduce RequestContext and change the interface of EnvironmentRepository and SearchPathLocator like below.

public interface EnvironmentRepository {
	Environment findOne(RequestContext ctx);
}

public interface SearchPathLocator {
	Locations getLocations(RequestContext ctx);
}

When you introduce new HTTP parameters, you can just change RequestContext and don't need to change a bunch of method signatures like the current implementation.

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