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

Add REDIS_HOST and POSTGRES_HOST Environment Variables to Example Voting App Configuration (Fixes #370) #386

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

agentmarketbot
Copy link

Pull Request Description

Overview

This pull request addresses issue #370, which proposes the ability to configure Redis and PostgreSQL hosts through environment variables instead of relying on hard-coded values. This change is particularly beneficial for users deploying the application in environments such as AWS EKS with ElastiCache and RDS.

Changes Made

The following modifications have been implemented to enable configuration via environment variables:

  1. Redis Connection:

    • Updated vote/app.py to replace the hardcoded Redis host with an environment variable. The new implementation uses os.getenv('REDIS_HOST', 'redis'), allowing users to specify a custom host while defaulting to 'redis' if the variable is unset.
  2. Postgres Connection:

    • Modified the connection string in result/server.js to utilize an environment variable for the Postgres hostname.
    • In worker/Program.cs, updated the connection settings for both Redis and Postgres to draw from environment variables instead of hardcoded values.
  3. Testing:

    • A test suite has been added to verify that the modifications function correctly, ensuring that the application can operate with both default settings ('redis' and db) and with user-specified values.

Rationale

The hard-coded values for Redis and Postgres made it challenging to adapt the application for different environments. By introducing environment variable configuration, we increase the flexibility of the application, enabling seamless integration with various deployments.

Validation

To validate the changes:

  • Existing tests have been executed successfully to confirm that functionality remains intact.
  • Custom environment variable settings have been tested to ensure the application correctly utilizes the specified configurations.

Additional Notes

  • For users deploying the application, make sure to define the environment variables REDIS_HOST and POSTGRES_HOST as needed to utilize this feature.

Conclusion

This enhancement improves the usability of the example voting app for a broader range of deployment scenarios and aligns with best practices for configuration management in modern applications.

Fixes #370

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.

Add REDIS_HOST and POSTGRES_HOST option from env
1 participant