Skip to content

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