Package org.togglz.mongodb
Class MongoStateRepository
java.lang.Object
org.togglz.mongodb.MongoStateRepository
- All Implemented Interfaces:
StateRepository
A state repository which stores the feature state in a MongoDB database.
The class provides a builder which can be used to configure the repository:
StateRepository repository = MongoStateRepository
.newBuilder(mongoClient, "mydb")
.collection("togglz")
.writeConcern(WriteConcern.REPLICA_ACKNOWLEDGED)
.build();
- Author:
- Christian Kaltepoth
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetFeatureState(Feature feature) static MongoStateRepository.BuildernewBuilder(com.mongodb.client.MongoClient client, String dbname) Creates a new builder for creating aMongoStateRepository.protected org.bson.DocumentvoidsetFeatureState(FeatureState featureState) protected com.mongodb.client.MongoCollection
-
Field Details
-
FIELD_FEATURE
- See Also:
-
FIELD_ENABLED
- See Also:
-
FIELD_STRATEGY
- See Also:
-
FIELD_PARAMS
- See Also:
-
mongoClient
protected final com.mongodb.client.MongoClient mongoClient -
dbname
-
collection
-
writeConcern
protected final com.mongodb.WriteConcern writeConcern
-
-
Method Details
-
getFeatureState
- Specified by:
getFeatureStatein interfaceStateRepository
-
setFeatureState
- Specified by:
setFeatureStatein interfaceStateRepository
-
queryFor
-
togglzCollection
protected com.mongodb.client.MongoCollection togglzCollection() -
newBuilder
public static MongoStateRepository.Builder newBuilder(com.mongodb.client.MongoClient client, String dbname) Creates a new builder for creating aMongoStateRepository.- Parameters:
client- the client instance to use for connecting to MongoDBdbname- the database name used for storing features state.
-