Skip to content

Conversation

@gytis
Copy link

@gytis gytis commented May 16, 2020

#9293
#9261

Sorry for a big PR. I wanted to squeeze the main changes in before the Tuesday's release. I kept two separate commits, but I can squash them if you prefer it.

The main changes are:

  • Rename the extension and all related modules from quarkus-panache-rest-* to quarkus-*-rest-data-panache
  • Move URL building logic (Path annotations and Location headers etc.) to one place outside of the method implementors.
  • Build controller path based on a resource rather than entity.
  • Make path configurable
  • Split @PanacheRestResource configuration annotation to two @ResourceProperties (to be used on an interface level and @OperationProperties (to be used on a method).

@boring-cyborg boring-cyborg bot added area/core area/dependencies Pull requests that update a dependency file area/infra-automation anything related to CI, bots, etc. that are used to automated our infrastructure area/panache labels May 16, 2020
@gytis
Copy link
Author

gytis commented May 16, 2020

cc @geoand

@geoand
Copy link
Contributor

geoand commented May 16, 2020

Thanks, I'll take a look first thing Monday.

I assume you also want a review from @FroMage ?

@gytis
Copy link
Author

gytis commented May 16, 2020

Yeah that would be helpful.

@geoand
Copy link
Contributor

geoand commented May 17, 2020

Can you please rebase onto master to pick up a CI fix?

Thanks

@gytis gytis force-pushed the panache-rest-paths branch from e53828c to eda585c Compare May 17, 2020 09:13
import io.quarkus.builder.item.MultiBuildItem;

public final class PanacheCrudResourceBuildItem extends MultiBuildItem {
public final class PanacheCrudResourceInfo extends MultiBuildItem {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why this was renamed?

Copy link
Author

Choose a reason for hiding this comment

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

Before it was already used by a processor which would extract separate bits of information and only pass what's needed to a specific method implementor. I made the method implementors more abstract now so processor wouldn't have to know too much details about them. Now it just passes this object to each implementor. So I assumed the name without "BuildItem" suffix would be more suitable. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

It just feels weird to have being a build item and not being called that. What we usually do in similar cases is to have a build item that just holds a reference to the regular class. Then in the non-build-step code you can just pass around the regular class. The build step classes would of course the build items to communicate.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah that makes sense, I'll extract it to a separate class

Copy link
Author

Choose a reason for hiding this comment

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

Done

return classInfo.classAnnotation(RESOURCE_PROPERTIES_ANNOTATION);
}
if (classInfo.superName() != null) {
ClassInfo superControllerInterface = index.getClassByName(classInfo.superName());
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nipick (can be fixed later): The use of controller seems a little out of place. Perhaps use resource instead?

Copy link
Author

Choose a reason for hiding this comment

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

True. I'll take a note of this and will fix it separately after the release.

Copy link
Author

Choose a reason for hiding this comment

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

Renamed


private static final String[] SUFFIXES = { "controller", "resource" };

public static String fromClass(Class<?> resourceClass) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be unused now, no?

Copy link
Author

Choose a reason for hiding this comment

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

True, I had a use for it initially. I'll get rid of it.

Copy link
Author

Choose a reason for hiding this comment

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

Removed

*
* Default: hyphenated resource name without a suffix. Ignored suffixes are `Controller` and `Resource`.
*/
String path() default "";
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that I think this will ever be an issue, but by using "" as the default value, you are effectively preventing users from making an panache rest data resource without a path. Now that's probably A good thing, but I am just bringing it up in case you hadn't considered it. In any case it would probably be safer to use some nonsensical default valur

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, we could maybe change this later too. Adding a nonsense value and based on that not add an annotation at all. I need to add some default value because otherwise user will always have to specify a path when using this annotation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I understand the need for a default value, just saying that "" is not the proper one :)

Copy link
Author

Choose a reason for hiding this comment

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

Shall we change it separately after the release? I don't want to hold this PR for too long.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure yeah

@gytis gytis force-pushed the panache-rest-paths branch from eda585c to 3fc8b60 Compare May 18, 2020 08:34
Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

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

Seems fine to me!

@gytis
Copy link
Author

gytis commented May 18, 2020

@geoand I've added modifications as a separate commit. I have to either keep them like this or squash all three commits (including the rename). Otherwise squashing first and third commits causes a lot of conflicts, so will take a lot of time to go through them.

@geoand
Copy link
Contributor

geoand commented May 18, 2020

I think we can live with the extra commit :)

@gsmet gsmet added this to the 1.5.0 milestone May 18, 2020
@gytis gytis force-pushed the panache-rest-paths branch from 3fc8b60 to cd4ae3d Compare May 18, 2020 10:00
@gytis gytis mentioned this pull request May 18, 2020
Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

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

Thanks for the quick work, and sorry about the late review. Aren't we missing the docs too?

@gytis gytis force-pushed the panache-rest-paths branch from cd4ae3d to 6c2b63c Compare May 18, 2020 16:31
@FroMage
Copy link
Member

FroMage commented May 18, 2020

OK, so we're only missing the docs, right?

@gytis
Copy link
Author

gytis commented May 18, 2020

I've just cherry-picked the docs commit from this PR #9254 so it would be easier for you to review and merge.

Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

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

OK, sorry I didn't realise we hadn't merged the docs PR yet. Thanks for bringing the commit over.

@gytis gytis force-pushed the panache-rest-paths branch from 2d69196 to 9215d9e Compare May 18, 2020 21:06
@gytis
Copy link
Author

gytis commented May 18, 2020

Thanks for the review @FroMage. I've committed and squashed your suggestions.

@gytis
Copy link
Author

gytis commented May 19, 2020

OpenID test failed the CI. Shouldn't be related to this PR.

@geoand
Copy link
Contributor

geoand commented May 19, 2020

OpenID test failed the CI. Shouldn't be related to this PR.

Yeah, it's a known flaky test

Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

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

Great!

@FroMage
Copy link
Member

FroMage commented May 19, 2020

I've restarted the CI tests

@gsmet gsmet force-pushed the panache-rest-paths branch 4 times, most recently from 9339c07 to aac0081 Compare May 20, 2020 07:03
@gytis
Copy link
Author

gytis commented May 20, 2020

"Native Tests - Data3" is the one that runs native tests for this extension. It passed our tests and later failed the Reactive Pg Client. It's not related with this change

@geoand
Copy link
Contributor

geoand commented May 20, 2020

"Native Tests - Data3" is the one that runs native tests for this extension. It passed our tests and later failed the Reactive Pg Client. It's not related with this change

Yeah, thats the reason we added --fail-at-end :)

@gsmet gsmet force-pushed the panache-rest-paths branch from aac0081 to deea0a5 Compare May 20, 2020 08:43
@gsmet gsmet merged commit 2de0459 into quarkusio:master May 20, 2020
@gytis gytis deleted the panache-rest-paths branch May 20, 2020 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core area/dependencies Pull requests that update a dependency file area/documentation area/infra-automation anything related to CI, bots, etc. that are used to automated our infrastructure area/panache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants