Skip to content

Commit

Permalink
allow env vars for k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshnsears committed Feb 13, 2019
1 parent 96b3891 commit b470fd4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/main/java/xqa/XqaQueryBalancerApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import io.dropwizard.jdbi3.JdbiFactory;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import xqa.health.QueryBalancerHealthCheck;
import xqa.resources.SearchResource;
import xqa.resources.XQueryResource;
Expand All @@ -20,6 +22,7 @@
import javax.servlet.FilterRegistration;

public class XqaQueryBalancerApplication extends Application<XqaQueryBalancerConfiguration> {
private static final Logger LOGGER = LoggerFactory.getLogger(XqaQueryBalancerApplication.class);
private final String serviceId;

public XqaQueryBalancerApplication() {
Expand Down Expand Up @@ -54,6 +57,8 @@ public void run(final XqaQueryBalancerConfiguration configuration, final Environ
environment.healthChecks().register("QueryBalancerHealthCheck", new QueryBalancerHealthCheck());

final JdbiFactory factory = new JdbiFactory();
LOGGER.info(String.format("databaseUrl=%s", configuration.getDataSourceFactory().getUrl()));

final Jdbi jdbi = factory.build(environment, configuration.getDataSourceFactory(), "postgresql");

environment.jersey().register(new SearchResource(jdbi));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/xqa/resources/XQueryResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public XQueryResource(final MessageBrokerConfiguration messageBrokerConfiguratio
synchronized (this) {
this.serviceId = serviceId;

LOGGER.info(String.format("messageBrokerHost=%s", messageBrokerConfiguration.getHost()));

messageBroker = new MessageBroker(messageBrokerConfiguration.getHost(), messageBrokerConfiguration.getPort(),
messageBrokerConfiguration.getUserName(), messageBrokerConfiguration.getPassword(),
messageBrokerConfiguration.getRetryAttempts());
Expand Down
4 changes: 2 additions & 2 deletions xqa-query-balancer.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ database:
driverClass: org.postgresql.Driver
user: xqa
password: xqa
url: jdbc:postgresql://0.0.0.0:5432/xqa
url: ${databaseUrl:- jdbc:postgresql://0.0.0.0:5432/xqa}
properties:
charSet: UTF-8
maxWaitForConnection: 5s
Expand All @@ -32,7 +32,7 @@ logging:
- type: console

messageBroker:
host: 0.0.0.0
host: ${messageBrokerHost:- 0.0.0.0}
port: 5672
userName: admin
password: admin
Expand Down
4 changes: 2 additions & 2 deletions xqa-query-balancer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ database:
driverClass: org.postgresql.Driver
user: xqa
password: xqa
url: jdbc:postgresql://xqa-db:5432/xqa
url: ${databaseUrl:- jdbc:postgresql://xqa-db:5432/xqa}
properties:
charSet: UTF-8
maxWaitForConnection: 5s
Expand All @@ -32,7 +32,7 @@ logging:
- type: console

messageBroker:
host: xqa-message-broker
host: ${messageBrokerHost:- xqa-message-broker}
port: 5672
userName: admin
password: admin
Expand Down

0 comments on commit b470fd4

Please sign in to comment.