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

fix(generator): add hostWithFallback #479

Merged
merged 4 commits into from
May 6, 2022
Merged

Conversation

shortcuts
Copy link
Member

@shortcuts shortcuts commented May 6, 2022

🧭 What and Why

🎟 JIRA Ticket: -

Changes included:

Follow up of #471

Adds a new hostWithFallback variable to avoid having to compute the domain etc.

It also allow path with other format to work (see #473)

🧪 Test

CI :D

@shortcuts shortcuts self-assigned this May 6, 2022
@netlify
Copy link

netlify bot commented May 6, 2022

Deploy Preview for api-clients-automation canceled.

Name Link
🔨 Latest commit d7688cf
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/62751e2916b5a90009a81c12

@algolia-bot
Copy link
Collaborator

algolia-bot commented May 6, 2022

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.

@shortcuts shortcuts requested review from a team, eunjae-lee and millotp and removed request for a team May 6, 2022 10:09
@shortcuts shortcuts marked this pull request as ready for review May 6, 2022 10:09
@shortcuts shortcuts marked this pull request as draft May 6, 2022 10:11
@shortcuts
Copy link
Member Author

shortcuts commented May 6, 2022

oops not good for now :D

edit: good now

@shortcuts shortcuts marked this pull request as ready for review May 6, 2022 10:26
@@ -38,7 +38,7 @@ export async function generate(

await generateOpenapitools(generators);

const availableWorkspaces = await run('yarn workspaces list', { verbose });
const availableWorkspaces = await run('yarn workspaces list');
Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot to push this fix last time

Copy link
Contributor

@damcou damcou left a comment

Choose a reason for hiding this comment

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

Just to be sure, does the CI currently checks the host for every client in every language ?

@@ -50,11 +50,11 @@ public class {{classname}} extends ApiClient {

{{^hasRegionalHost}}
public {{classname}}(String appId, String apiKey) {
this(appId, apiKey, new HttpRequester(getDefaultHosts({{^isExperimentalHost}}appId{{/isExperimentalHost}})), null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this variable isExperimentalHost created ? Is there any reason why it's used in the java and javascript templates and not in the php one ? Did I miss something ?

Copy link
Member Author

Choose a reason for hiding this comment

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

You missed it because you did not generated the Predict client for PHP

It was there because the URL was not following the correct schema, but in fact the ew value was a region.

We now don't use this variable anymore

@@ -102,7 +102,8 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
// If a list of hosts was passed, we ignore the cache
$clusterHosts = ClusterHosts::create($hosts);
} else {
$clusterHosts = ClusterHosts::create('{{host}}.'.$config->getRegion().'.algolia.{{topLevelDomain}}');
$url = str_replace('{region}', $config->getRegion(), '{{{host}}}');
Copy link
Contributor

Choose a reason for hiding this comment

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

What does the {{{host}}} variable is supposed to contain now ? Has it changed ? Before it was "analytics", "insights", ... no ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, but it contained a lot of logic like topLevelDomain etc.

It stores the whole domain now, and we only replace the region accordingly, so we don't have to compute other stuff than host

For insights for example its value is insights.{region}.algolia.io, so we only replace the {region} field with the region value

Copy link
Member Author

@shortcuts shortcuts May 6, 2022

Choose a reason for hiding this comment

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

You can see it in action here btw: dd5d4db

to make sure the logic is right for PHP

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I see, looks good then 👍

@shortcuts
Copy link
Member Author

Just to be sure, does the CI currently checks the host for every client in every language ?

Only JavaScript have the client tests

@shortcuts shortcuts requested a review from damcou May 6, 2022 13:05
Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

Always good to add flexibility 💯

}
if (fallbackToAliasHost) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you don't need the if here, we won't read it anyway if fallbacktoAliasHost is false.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Done d7688cf

@@ -10,7 +10,12 @@ components:
apiKey:
$ref: '../common/securitySchemes.yml#/apiKey'
servers:
- url: https://predict-api-432xa6wemq-ew.a.run.app
- url: https://predict-api-432xa6wemq-{region}.a.run.app
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should switch the order of the stack PR so this doesn't appear here.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not the same change as in #473, it just fixes the spec because ew is in fact a region

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah ok I didn't know ! Which region is it ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Western Europe I believe? cc @anghelalexandra :D

Copy link
Collaborator

Choose a reason for hiding this comment

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

Europe West ? 🤨

Copy link
Member Author

Choose a reason for hiding this comment

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

@shortcuts shortcuts enabled auto-merge (squash) May 6, 2022 13:11
@damcou
Copy link
Contributor

damcou commented May 6, 2022

Just to be sure, does the CI currently checks the host for every client in every language ?

Only JavaScript have the client tests

Ok, I created a ticket about it for PHP https://algolia.atlassian.net/browse/APIC-466

@shortcuts
Copy link
Member Author

Ok, I created a ticket about it for PHP https://algolia.atlassian.net/browse/APIC-466

Thanks! We indeed need one for Java too

@damcou
Copy link
Contributor

damcou commented May 6, 2022

Ok, I created a ticket about it for PHP https://algolia.atlassian.net/browse/APIC-466

Thanks! We indeed need one for Java too

Done : https://algolia.atlassian.net/browse/APIC-467

@shortcuts shortcuts merged commit 68ad731 into main May 6, 2022
@shortcuts shortcuts deleted the fix/generators-servers branch May 6, 2022 13:20
This was referenced May 19, 2022
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.

4 participants