use of keywhiz.service.config.Readonly in project keywhiz by square.
the class ServiceModule 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;
}
use of keywhiz.service.config.Readonly in project keywhiz by square.
the class ServiceModule method readonlyJooqContext.
@Provides
@Singleton
@Readonly
DSLContext readonlyJooqContext(@Readonly ManagedDataSource dataSource) throws SQLException {
DSLContext dslContext = DSLContexts.databaseAgnostic(dataSource);
org.jooq.Configuration configuration = dslContext.configuration();
// Disable support for nested transactions via savepoints (required for MySQL)
// See: https://groups.google.com/forum/#!topic/jooq-user/zG0U6CkxI5o
configuration.set(new DefaultTransactionProvider(configuration.connectionProvider(), false));
return dslContext;
}
Aggregations