Last active
August 29, 2015 14:01
-
-
Save stuartgunter/56a3c43f2fd873a8f6bf to your computer and use it in GitHub Desktop.
dropwizard-cassandra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using an exponential reconnection policy | |
reconnectionPolicy: | |
type: exponential | |
baseDelay: 10 milliseconds | |
maxDelay: 1 second | |
# using a constant reconnection policy | |
reconnectionPolicy: | |
type: constant | |
delay: 10 milliseconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.stuartgunter</groupId> | |
<artifactId>dropwizard-cassandra</artifactId> | |
<version>${dropwizard-cassandra.version}</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class YourApp extends Application<YourAppConfig> { | |
private final CassandraBundle<YourAppConfig> cassandra = | |
new CassandraBundle<YourAppConfig>() { | |
@Override | |
protected CassandraFactory cassandraConfiguration(YourAppConfig appConfig) { | |
return appConfig.getCassandraConfig(); | |
} | |
}; | |
@Override | |
public void initialize(Bootstrap<CassandraBundleConfiguration> bootstrap) { | |
bootstrap.addBundle(cassandra); | |
} | |
@Override | |
public void run(YourAppConfig configuration, Environment environment) throws Exception { | |
/* | |
* you can now use `cassandra.getCluster()` to use the cluster instance in your app, | |
* or pass around a SessionFactory with `cassandra.getSessionFactory()` if you just need | |
* to be able to create new sessions without knowing whether a keyspace was configured | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment