-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(java): replace EchoRequester by Interceptor APIC-522 #648
Conversation
✅ Deploy Preview for api-clients-automation canceled.
|
✗ The generated branch has been deleted.If the PR has been merged, you can check the generated code on the |
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.
Looks very nice and useful !
So if I understand correctly, the whole purpose to switch to EchoInterceptor
was to be able to run all the tests and you only use it there ?
Not sure why the CI breaks though
Moving the echo requester further allows us to test the retry strategy too, which was not possible before, and we can add more test for this, now it's pretty light |
@@ -11,7 +11,7 @@ | |||
}, | |||
"expected": { | |||
"type": "userAgent", | |||
"match": "^Algolia for ${{languageCased}} \\(\\d+\\.\\d+\\.\\d+\\)(; [a-zA-Z. ]+ (\\(\\d+\\.\\d+\\.\\d+\\))?)*(; ${{clientPascalCase}} (\\(\\d+\\.\\d+\\.\\d+\\)))(; [a-zA-Z. ]+ (\\(\\d+\\.\\d+\\.\\d+\\))?)*$" | |||
"match": "^Algolia for ${{languageCased}} \\(\\d+\\.\\d+\\.\\d+(-.*)?\\)(; [a-zA-Z. ]+ (\\(\\d+\\.\\d+\\.\\d+(-.*)?\\))?)*(; ${{clientPascalCase}} (\\(\\d+\\.\\d+\\.\\d+(-.*)?\\)))(; [a-zA-Z. ]+ (\\(\\d+\\.\\d+\\.\\d+(-.*)?\\))?)*$" |
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.
Looks like @shortcuts has made the same type of change on this file here: https://github.com/algolia/api-clients-automation/pull/649/files#diff-ce73ada5d4570ce8f0a1c895da4aa18821af7288c35b066005850722ecde9b66R14
:D
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.
yep but it's closed now ahah
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.
🚀
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.
Nice! Small comments about docs
@@ -0,0 +1,91 @@ | |||
package com.algolia; |
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 mention echoRequester for all clients in #564, we will need to update this part for client specific)
tests/output/java/src/test/java/com/algolia/EchoInterceptor.java
Outdated
Show resolved
Hide resolved
^Algolia for <LANGUAGE> \\(\\d+\\.\\d+\\.\\d+(-.*)?\\)(; [a-zA-Z. ]+ (\\(\\d+\\.\\d+\\.\\d+(-.*)?\\))?)*(; <CLIENT> (\\(\\d+\\.\\d+\\.\\d+(-.*)?\\)))(; [a-zA-Z. ]+ (\\(\\d+\\.\\d+\\.\\d+(-.*)?\\))?)*$ | ||
``` | ||
|
||
The function MUST be named `addAlgoliaAgent` because of JavaScript exception that doesn't allow custom `User-Agent` in the header, and must use `x-algolia-agent` for JavaScript. |
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 is a bit confusing but I don't know how to word it better, actually only JS is named addAlgoliaAgent
, because we allow appending to the client UA
In other clients, it's setAlgoliaAgent
because it overrides everything, no?
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.
yes it's not the same behavior, in js you can never override the user agent it seems like, only add segment
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.
ah yes you can pass a custom header directly
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.
I will remove setAlgoliaAgent
in the next PR for java and php
client: `; Search (5.0.0)` | ||
segment: `; JVM (11.0.14); experimental` | ||
``` | ||
- base: `Algolia for Java (4.0.0)` |
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.
For this example it should follow the shape of the result so it's base
-> segment
-> client
for Java
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.
it depends in which order you add the segments
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.
and this is the actual user agent returned by the client
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.
Yes but in your example client is added before segments but the output states JVM in second
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.
Ah you consider the example is using the Java client, globally reading (without knowledge of clients), it feels like it's magically reordered but I don't think we mind
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.
Maybe we should differenciate internal segments
and user defined segments
, but this is a confusion we don't need to add in this doc.
JVM
is an internal segment
, and will be added at the creation, then Search
is added, and finally the user defined segments
are added.
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.
Looks good!!
🧭 What and Why
🎟 JIRA Ticket: APIC-522
Remove the obsolete
EchoRequester
and replace it with the much betterEchoInterceptor
, allowing access to the data after the retry strategy, like the host.🧪 Test
CI