Is it possible to have an optional database?

37 views
Skip to first unread message

Jay Goldberg

unread,
Sep 25, 2017, 11:35:46 AM9/25/17
to dropwizard-dev
I have two services which I wish to merge. One has a database dependency and the other does not. If I wish to merge these services and only wish to enable the non-database dependent service it still requires me to configure a database.
Is there a way to allow dropwizard not to have to have a database when not needed?

Ryan Kennedy

unread,
Sep 25, 2017, 12:38:39 PM9/25/17
to dropwizard-dev
Can you not set the database configuration as optional and only set up the database bits when one is present?

On Mon, Sep 25, 2017 at 8:35 AM Jay Goldberg <jay...@gmail.com> wrote:
I have two services which I wish to merge. One has a database dependency and the other does not. If I wish to merge these services and only wish to enable the non-database dependent service it still requires me to configure a database.
Is there a way to allow dropwizard not to have to have a database when not needed?

--
You received this message because you are subscribed to the Google Groups "dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jay Goldberg

unread,
Sep 25, 2017, 1:27:25 PM9/25/17
to dropwiz...@googlegroups.com
Those fields are predefined and are not optional

On Mon, Sep 25, 2017 at 11:38 AM, Ryan Kennedy <rcke...@gmail.com> wrote:
Can you not set the database configuration as optional and only set up the database bits when one is present?

On Mon, Sep 25, 2017 at 8:35 AM Jay Goldberg <jay...@gmail.com> wrote:
I have two services which I wish to merge. One has a database dependency and the other does not. If I wish to merge these services and only wish to enable the non-database dependent service it still requires me to configure a database.
Is there a way to allow dropwizard not to have to have a database when not needed?

--
You received this message because you are subscribed to the Google Groups "dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-dev/eB9Dua4JGzc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-dev+unsubscribe@googlegroups.com.

Ryan Kennedy

unread,
Sep 25, 2017, 1:54:47 PM9/25/17
to dropwiz...@googlegroups.com
Not sure I follow. Any chance you can share your Configuration class (redacted/fuzzed would be fine)?

On Mon, Sep 25, 2017 at 10:27 AM Jay Goldberg <jay...@gmail.com> wrote:
Those fields are predefined and are not optional

On Mon, Sep 25, 2017 at 11:38 AM, Ryan Kennedy <rcke...@gmail.com> wrote:
Can you not set the database configuration as optional and only set up the database bits when one is present?

On Mon, Sep 25, 2017 at 8:35 AM Jay Goldberg <jay...@gmail.com> wrote:
I have two services which I wish to merge. One has a database dependency and the other does not. If I wish to merge these services and only wish to enable the non-database dependent service it still requires me to configure a database.
Is there a way to allow dropwizard not to have to have a database when not needed?

--
You received this message because you are subscribed to the Google Groups "dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-de...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-dev/eB9Dua4JGzc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-de...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-de...@googlegroups.com.

Evan Meagher

unread,
Sep 25, 2017, 1:56:43 PM9/25/17
to dropwiz...@googlegroups.com
+dropwizard-user, dropwizard-dev to bcc

Hello Jay,

Which fields are you referring to, exactly? I think what Ryan was suggesting is to put an Optional<DataSourceFactory> in your applications' configuration classes. If the optional is present, then the DataSourceFactory can be initialized and integrated in the app. Otherwise, it's ignored, and the app continues along in a database-less state.

I've used this technique in the past with services that can optionally include a Redis caching layer. Subclasses of io.dropwizard.Configuration can have optional fields and these fields will be properly populated based on the presence or absence of the corresponding parameters in the YAML config file.

On Mon, Sep 25, 2017 at 10:54 AM, Ryan Kennedy <rcke...@gmail.com> wrote:
Not sure I follow. Any chance you can share your Configuration class (redacted/fuzzed would be fine)?
On Mon, Sep 25, 2017 at 10:27 AM Jay Goldberg <jay...@gmail.com> wrote:
Those fields are predefined and are not optional

On Mon, Sep 25, 2017 at 11:38 AM, Ryan Kennedy <rcke...@gmail.com> wrote:
Can you not set the database configuration as optional and only set up the database bits when one is present?

On Mon, Sep 25, 2017 at 8:35 AM Jay Goldberg <jay...@gmail.com> wrote:
I have two services which I wish to merge. One has a database dependency and the other does not. If I wish to merge these services and only wish to enable the non-database dependent service it still requires me to configure a database.
Is there a way to allow dropwizard not to have to have a database when not needed?

--
You received this message because you are subscribed to the Google Groups "dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-dev/eB9Dua4JGzc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages