Search in sources :

Example 1 with JooqHealthCheck

use of keywhiz.JooqHealthCheck in project keywhiz by square.

the class ServiceDataSourceModule method readonlyDataSource.

@Provides
@Singleton
@Readonly
ManagedDataSource readonlyDataSource(Environment environment, KeywhizConfig config) {
    DataSourceFactory dataSourceFactory = config.getReadonlyDataSourceFactory();
    ManagedDataSource dataSource = dataSourceFactory.build(environment.metrics(), "db-readonly");
    environment.lifecycle().manage(dataSource);
    environment.healthChecks().register("db-readonly-health", new JooqHealthCheck(dataSource, RETURN_UNHEALTHY));
    return dataSource;
}
Also used : JooqHealthCheck(keywhiz.JooqHealthCheck) DataSourceFactory(io.dropwizard.db.DataSourceFactory) ManagedDataSource(io.dropwizard.db.ManagedDataSource) Readonly(keywhiz.service.config.Readonly) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 2 with JooqHealthCheck

use of keywhiz.JooqHealthCheck in project keywhiz by square.

the class ServiceDataSourceModule method dataSource.

@Provides
@Singleton
ManagedDataSource dataSource(Environment environment, KeywhizConfig config) {
    DataSourceFactory dataSourceFactory = config.getDataSourceFactory();
    ManagedDataSource dataSource = dataSourceFactory.build(environment.metrics(), "db-writable");
    environment.lifecycle().manage(dataSource);
    environment.healthChecks().register("db-read-write-health", new JooqHealthCheck(dataSource, LOG_ONLY));
    return dataSource;
}
Also used : JooqHealthCheck(keywhiz.JooqHealthCheck) DataSourceFactory(io.dropwizard.db.DataSourceFactory) ManagedDataSource(io.dropwizard.db.ManagedDataSource) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)2 Singleton (com.google.inject.Singleton)2 DataSourceFactory (io.dropwizard.db.DataSourceFactory)2 ManagedDataSource (io.dropwizard.db.ManagedDataSource)2 JooqHealthCheck (keywhiz.JooqHealthCheck)2 Readonly (keywhiz.service.config.Readonly)1