public class MongoStateRepository extends Object implements 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();
| Modifier and Type | Class and Description |
|---|---|
static class |
MongoStateRepository.Builder
Builder for a
MongoStateRepository. |
| Modifier and Type | Field and Description |
|---|---|
protected String |
collection |
protected String |
dbname |
protected static String |
FIELD_ENABLED |
protected static String |
FIELD_FEATURE |
protected static String |
FIELD_PARAMS |
protected static String |
FIELD_STRATEGY |
protected com.mongodb.client.MongoClient |
mongoClient |
protected com.mongodb.WriteConcern |
writeConcern |
| Modifier and Type | Method and Description |
|---|---|
FeatureState |
getFeatureState(Feature feature) |
static MongoStateRepository.Builder |
newBuilder(com.mongodb.client.MongoClient client,
String dbname)
Creates a new builder for creating a
MongoStateRepository. |
protected org.bson.Document |
queryFor(Feature feature) |
void |
setFeatureState(FeatureState featureState) |
protected com.mongodb.client.MongoCollection |
togglzCollection() |
protected static final String FIELD_FEATURE
protected static final String FIELD_ENABLED
protected static final String FIELD_STRATEGY
protected static final String FIELD_PARAMS
protected final com.mongodb.client.MongoClient mongoClient
protected final String dbname
protected final String collection
protected final com.mongodb.WriteConcern writeConcern
public FeatureState getFeatureState(Feature feature)
getFeatureState in interface StateRepositorypublic void setFeatureState(FeatureState featureState)
setFeatureState in interface StateRepositoryprotected org.bson.Document queryFor(Feature feature)
protected com.mongodb.client.MongoCollection togglzCollection()
public static MongoStateRepository.Builder newBuilder(com.mongodb.client.MongoClient client, String dbname)
MongoStateRepository.client - the client instance to use for connecting to MongoDBdbname - the database name used for storing features state.Copyright © 2021. All rights reserved.