-
Notifications
You must be signed in to change notification settings - Fork 36
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
Update cache SPI and resource serialization #92
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @wzy1935 ! I did a first round of comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @wzy1935 , I've added another batch of comments
Can you also add a test that verifies the behavior of a shared cached? That is, if it has stored a response for a one reverse proxy instance, another proxy instance will not have to contact the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @wzy1935 ! Some more comments
Can you please rebase this PR? Thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @wzy1935 , another batch of reviews
@@ -15,6 +15,7 @@ | |||
import io.vertx.codegen.annotations.VertxGen; | |||
import io.vertx.core.Future; | |||
import io.vertx.core.Handler; | |||
import io.vertx.core.Vertx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import io.vertx.core.Vertx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a leftover from a previous change?
|
||
/** | ||
* Default constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Default constructor | |
* Default constructor. |
The Javadoc convention mandates there must be a first sentence ending with period.
Can you please do the same with other Javadoc comments?
|
||
@Override | ||
public Future<Void> close() { | ||
return Future.succeededFuture(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't talk about clearing the map on close, did we? Would it be necessary in your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I also think there's no need, but when I called the vertx.createSharedResource()
in ReverseProxy#newCache
, there's a closeFuture
that I don't know how to deal with it.
Maybe you could check if the following would work? I think I should change to this version:
// ReverseProxy#newCache
public Cache newCache(CacheOptions options, Vertx vertx) {
if (options.getShared()) {
CloseFuture closeFuture = new CloseFuture();
return ((VertxInternal) vertx).createSharedResource("__vertx.shared.proxyCache", options.getName(), closeFuture, (cf_) -> {
Cache cache = new CacheImpl(options);
return cache;
});
}
return new CacheImpl(options);
}
|
||
/** | ||
* Cache SPI. | ||
*/ | ||
public interface Cache<K, V> extends Map<K, V> { | ||
public interface Cache { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add @Unstable
here as we might want to evolve the SPI after the initial design
} | ||
|
||
public void fillResponseFromResource(ProxyResponse proxyResponse, Resource resource) { | ||
proxyResponse.setStatusCode(200); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using the status code of the resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part of the code is moved from Resource#init
where it uses 200 in the original code. In PR I don't want to change any logic so I left it in here, instead I made this change in #93
|
||
public class ResourceParseTest { | ||
|
||
public static boolean weakEquals(Resource r1, Resource r2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why weakEquals
? Which are the fields we don't want to compare?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A silly reason cause the full equals is rather too long to implement... I can add them back though
Closes #67
Updated the cache SPI and added serialization for the
Resource
class.