Skip to content

Commit

Permalink
fix(clients): monitoring for JavaScript and Python (#2568)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Jan 18, 2024
1 parent 79f8eb5 commit 99ce6db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion templates/javascript/clients/api-single.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function create{{#lambda.titlecase}}{{apiName}}{{/lambda.titlecase}}({
}: CreateClientOptions{{#hasRegionalHost}} & {region{{#fallbackToAliasHost}}?{{/fallbackToAliasHost}}: Region }{{/hasRegionalHost}}) {
const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts({{^hasRegionalHost}}appIdOption{{/hasRegionalHost}}{{#hasRegionalHost}}regionOption{{/hasRegionalHost}}),
hosts: getDefaultHosts({{^hasRegionalHost}}{{^uniqueHost}}appIdOption{{/uniqueHost}}{{/hasRegionalHost}}{{#hasRegionalHost}}regionOption{{/hasRegionalHost}}),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
Expand Down
9 changes: 7 additions & 2 deletions templates/javascript/clients/client/api/hosts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export type Region = (typeof REGIONS)[number];
{{/hasRegionalHost}}

{{^hasRegionalHost}}
function getDefaultHosts(appId: string): Host[] {
function getDefaultHosts({{^uniqueHost}}appId: string{{/uniqueHost}}): Host[] {
{{#uniqueHost}}
return [{url: "{{{uniqueHost}}}", accept: 'readWrite', protocol: 'https' }];
{{/uniqueHost}}
{{^uniqueHost}}
return (
[
{
Expand Down Expand Up @@ -37,6 +41,7 @@ function getDefaultHosts(appId: string): Host[] {
},
])
);
{{/uniqueHost}}
}
{{/hasRegionalHost}}

Expand All @@ -46,4 +51,4 @@ function getDefaultHosts(region{{#fallbackToAliasHost}}?{{/fallbackToAliasHost}}

return [{ url, accept: 'readWrite', protocol: 'https' }];
}
{{/hasRegionalHost}}
{{/hasRegionalHost}}
7 changes: 7 additions & 0 deletions templates/python/config.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,19 @@ class {{#lambda.pascalcase}}{{client}}{{/lambda.pascalcase}}Config(BaseConfig):

{{^hasRegionalHost}}
self.hosts = HostsCollection(
{{#uniqueHost}}
[
Host("{{{uniqueHost}}}"),
]
{{/uniqueHost}}
{{^uniqueHost}}
[
Host("{}-dsn.algolia.net".format(self.app_id), 10, CallType.READ),
Host("{}.algolia.net".format(self.app_id), 10, CallType.WRITE),
Host("{}-1.algolianet.com".format(self.app_id)),
Host("{}-2.algolianet.com".format(self.app_id)),
Host("{}-3.algolianet.com".format(self.app_id)),
]
{{/uniqueHost}}
)
{{/hasRegionalHost}}

0 comments on commit 99ce6db

Please sign in to comment.