Skip to content

Update Ruby-pg samples and README.md#117

Merged
wcmjunior merged 6 commits intomainfrom
ruby_samples
May 7, 2025
Merged

Update Ruby-pg samples and README.md#117
wcmjunior merged 6 commits intomainfrom
ruby_samples

Conversation

@leszek-bq
Copy link
Copy Markdown
Contributor

This PR updates the Ruby-pg example.

Description of changes:

  • Add non-admin connection example
  • Split connection creation logic into a method to address token refresh concerns
  • Clean up and improve the documentation/comments

By submitting this pull request, I confirm that my contribution is made under
the terms of the MIT-0 license.

@wcmjunior wcmjunior requested a review from trstephen-amazon May 5, 2025 22:53
Copy link
Copy Markdown
Collaborator

@trstephen-amazon trstephen-amazon left a comment

Choose a reason for hiding this comment

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

Overall looks fine but at minimum the license comment needs to be retained.

Comment thread ruby/ruby-pg/Gemfile Outdated
gem 'aws-sigv4', '1.10.1'

gem "aws-sdk-dsql", "~> 1"
gem 'aws-sdk-core', '3.216.0'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: don't think this is needed, was just for hand-rolled sigv4 token generation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed

Comment thread ruby/ruby-pg/README.md Outdated
ruby --version
```

For example: `v3.2.6"`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: CI is using 2.5 which has been EOL since 2017. Can update in a separate PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, initially in line 53 we used to have

Ensure you have ruby v2.5+ installed

We changed it to

.. have ruby v3.2+ installed

Should we revert line 53 to v2.5?

Perhaps the line 61 stating

For example: v3.2.6"

Is not even needed?

Comment thread ruby/ruby-pg/README.md Outdated
### Set the environmet variables specifying cluster endpoint, region and cluster user

```
# e.g. 'admin' or 'non_admin_user'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: implies two valid values. Can leave this open ended with something like "e.g. 'admin' or a custom user"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed

Comment thread ruby/ruby-pg/README.md

rspec
# e.g. "us-east-1"
export REGION="<your cluster region>"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: other examples call this CLUSTER_REGION

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree that it would probably be better and consistent with the other related variable names. However, most languages at the moment call it REGION in code samples and readme.md.

Exceptions:
Java, typescript and secret variable names in GitHub action yml files.

I guess we should standardize? Make all to use CLUSTER_REGION?

Comment thread ruby/ruby-pg/README.md
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Execute the following command:

SPDX-License-Identifier: MIT-0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

License ID should be retained

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-added.

Comment thread ruby/ruby-pg/lib/hello_dsql.rb Outdated
Comment on lines +18 to +21
password_token = token_generator.generate_db_connect_auth_token({
:endpoint => cluster_endpoint,
:region => region
})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: file mixes hash styles. PG.connect uses implicit hashes (no {}) and map syntax but token methods above use explicit hashes and 'hash rockets'. See this file for a token generator with the PG.connect style syntax.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed

Comment thread ruby/ruby-pg/README.md Outdated

Before using the Ruby-pg driver, ensure you have the following prerequisites installed:
Ruby: Ensure you have ruby v3.2+ installed from the [official website](https://www.ruby-lang.org/en/documentation/installation/).
Ruby: Ensure you have ruby v2.5+ installed from the [official website](https://www.ruby-lang.org/en/documentation/installation/).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Disagree here since the version has been EOL for over 7 years. If something breaks because our ruby version is too old we're unlikely to backport a fix and just drop compatibility. Might as well short-circuit that now and bump the supported version. Can you update the CI to use ruby 3+?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -51,6 +51,8 @@ jobs:
env:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

bah, L37 and L40 are out of scope for "suggest changes" functionality.

anyway! Can you change those 2.5 -> 3.3 so CI builds against our advertised supported version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚢

@@ -51,6 +51,8 @@ jobs:
env:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚢

@wcmjunior wcmjunior merged commit c335a05 into main May 7, 2025
3 checks passed
@wcmjunior wcmjunior deleted the ruby_samples branch May 7, 2025 00:35
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