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 cloud resource naming #1099

Merged
merged 4 commits into from
May 18, 2022
Merged

Fix cloud resource naming #1099

merged 4 commits into from
May 18, 2022

Conversation

amarthadan
Copy link
Contributor

Issue AN-737

I've introduced two naming changes:

  • I've removed unnecessary suffixes from resource names (e.g. there's no need to add -role to the role name as it's under roles in the dashboard)
  • I've shortened the names of cloud resources, changing processHttpSignedDataRequest to handleHttpSignedReq and httpSignedDataGateway to httpSignedGw. I changed this only for the cloud resource names and not throughout the whole codebase because I would ideally have to change also the fields in the configuration. I know these names are not ideal, I'm open to suggestions, I'm not good at naming stuff 😄

The longest names for cloud resources possible with these changes are:
airnode-0123456-0123456789abcdef-handleHttpSignedReq-schedule (61 characters)
airnode-0123456-0123456789abcdef-httpSignedGw-lambda-invoke (59 characters)
for AWS and
airnode-0123456-0123456789abcdef-handleHttpSignedReq-scheduler (62 characters)
airnode-0123456-0123456789abcdef-httpSignedGw (45 characters)
for GCP which is within the common maximal 64 characters restriction.

@amarthadan amarthadan requested a review from a team May 17, 2022 08:17
@amarthadan amarthadan self-assigned this May 17, 2022
Copy link
Contributor

@Siegrift Siegrift left a comment

Choose a reason for hiding this comment

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

I think it would be better to address this properly and I think what I've proposed here shouldn't be that hard to implement.

@@ -8,9 +8,9 @@
coverage/

# Config files
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to mention that this is deliberate so the next me won't update this.

@@ -18,12 +18,12 @@ export async function run(...args: unknown[]) {
return handler.run(...args);
}

export async function processHttpRequest(...args: unknown[]) {
export async function handleHttpReq(...args: unknown[]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to add a comment explaining why is the fn name abbreviated? We are consistent in naming in Airnode and this is tempting to rename...

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Also maybe better name would be httpRequest (dropping the "handle" part)

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, after thinking about this more I dislike that the "function name length" pollutes the deployer handlers... I'd propose the following. Create a file entrypoint which will be called by TF and rename the current index file to implementation.

The entrypoint file should be documented that it exist because the function name length is restricted, but the implementation can be named freely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't follow. But I can rename the functions just here, in entrypoint.ts, and leave the handlers (those in aws and gcp directories) as they were. But that feels even less consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I missed that we already have the entrypoint.ts file. I'd change the function names in this file and document that this is needed because of GCP/AWS.

This allows us to deal with that problem only in entrypoint and use whatever name we want in the rest of the codebase.

@@ -18,12 +18,13 @@ export async function run(...args: unknown[]) {
return handler.run(...args);
}

export async function processHttpRequest(...args: unknown[]) {
// We shorten function names to allow for shorter cloud resource names
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd either copy this command above every function (preferred) or make it a top level command.

@amarthadan amarthadan requested a review from Siegrift May 18, 2022 06:57
Copy link
Contributor

@Siegrift Siegrift left a comment

Choose a reason for hiding this comment

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

@amarthadan amarthadan merged commit dd140e3 into master May 18, 2022
@amarthadan amarthadan deleted the fix-cloud-resource-naming branch May 18, 2022 08:05
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.

2 participants