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 retry mechanism for MongoDB connection #17

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

Add retry mechanism for MongoDB connection #17

wants to merge 1 commit into from

Conversation

straurob
Copy link

This PR adds a configurable retry mechanism when connecting to a MongoDB instance.

Motivation

When running MailHog with MongoDB In a containerized environment, it is likely that starting the MongoDB service needs longer than starting MailHog. In this case, MailHog does a fallback to its in-memory storage without further notification. This is probably not what you want when running a MongoDB.

Description

This PR adds three new configuration options:

  • MongoRetries
  • MongoRetryInterval
  • InMemoryFallback

When having configured MongoDB, MailHog will execute MongoRetries attempts for a successful connection. Between each attempts it will wait for MongoRetryInterval seconds. If the connection is not successful, it will either exit (InMemoryFallback = false) or use in-memory storage (InMemoryFallback = true).

Add retry mechanism for MongoDB connection
@gedge
Copy link
Member

gedge commented Sep 29, 2021

does this supercede #16 ?

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