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

Stop API startup if the database connection fails #71

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

Conversation

kthchew
Copy link
Contributor

@kthchew kthchew commented Apr 29, 2023

Issue

If the database can't be connected to (e.g. it is not running or the .env file is set incorrectly), the API may still startup without any indication that the connection failed. This can lead to confusion if certain things don't work.

Description

As the API is essentially useless without the database, it will panic on startup if the database connection fails. This seems to be the intention based on the surrounding code, but sql.Open doesn't actually give an error in this case because it doesn't necessarily create a connection immediately.

Type Of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Test Steps

Start the API without the database active

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Formatting

Please use markdown in your pull request message. A useful summary of commands can be found here.

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.

1 participant