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

[Proposal] Use std-uritemplate instead of maintaining a separate implementation #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

andreaTP
Copy link

👋 Hi there, and thanks for the great project!
This is a proposal that I'd like to evaluate with this project maintainers.

In the Kiota project we faced the challenge of having to support implementations of uri-template in various languages, for this and more motivations we ended up rolling out a new one: std-uritemplate .

More recently I created a Quarkus-Kiota extension and alternative libraries, as expected, the provided Http Client implementation for the Quarkus integration is based on VertX 🙂 .

Now, having two independent implementations of the same (simple)algorithm on the classpath doesn't surely hurt much the users, but, merging the efforts has a couple of pretty interesting benefits:

  • the implementation will become more robust over time
  • single source of truth
  • larger maintainers base
  • larger users base
  • reduced maintainer's effort

With this PR I'm tentatively spearheading the collaboration opportunity, showing the tradeoffs of the approach in it's practical implementation.

Additional notes:
talking about performance, in the early days of std-uritemplate I have been assisted by @franz1981 and I just updated a quick JMH benchmark to demonstrate that the two implementation have comparable results.

Happy to hear your thoughts!

@@ -77,7 +77,7 @@ public void testSimpleStringExpansion() {
assertEquals("one=1,two=2,three=3,comma=%2C", UriTemplate.of("{map*}").expandToString(variables));
assertEquals("", UriTemplate.of("{empty_map}").expandToString(variables));
assertEquals("", UriTemplate.of("{empty_map*}").expandToString(variables));
assertExpansionFailure("{list:1}");
Copy link
Author

Choose a reason for hiding this comment

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

I belive this is a bug in the current implementation and the updated result is the expected one.

}
return pos;
}
private List<String> extractTokens() {
Copy link
Author

Choose a reason for hiding this comment

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

The diff in GH looks pretty ugly, anyhow, to respect the current option to throw an exception on missing keys (which is a usability "extra" on top of the original spec), I implemented a single pass extraction of the tokens as an additional validation step.

@andreaTP
Copy link
Author

cc. @cescoffier

@andreaTP andreaTP marked this pull request as ready for review June 25, 2024 14:37
@andreaTP
Copy link
Author

@cescoffier @vietj are you interested into(ever) going down this path, or do you want me to close the PR?

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.

1 participant