mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-09 05:12:12 +02:00
Make Cassandra replication factor configurable (issue #787)
Add CASSANDRA_REPLICATION_FACTOR environment variable and --cassandra-replication-factor CLI argument to cassandra_config.py. Update all four table store constructors (ConfigTableStore, KnowledgeTableStore, LibraryTableStore, IamTableStore) to accept an optional replication_factor parameter and use it in keyspace creation CQL queries. Thread the replication factor through all service constructors: Configuration, KnowledgeManager, Librarian, IamService, and knowledge store Processor.
This commit is contained in:
parent
1ffae12559
commit
67cbd69b8f
10 changed files with 46 additions and 20 deletions
|
|
@ -40,9 +40,11 @@ class LibraryTableStore:
|
|||
def __init__(
|
||||
self,
|
||||
cassandra_host, cassandra_username, cassandra_password, keyspace,
|
||||
replication_factor=1,
|
||||
):
|
||||
|
||||
self.keyspace = keyspace
|
||||
self.replication_factor = replication_factor
|
||||
|
||||
logger.info("Connecting to Cassandra...")
|
||||
|
||||
|
|
@ -77,12 +79,11 @@ class LibraryTableStore:
|
|||
|
||||
logger.debug("Keyspace...")
|
||||
|
||||
# FIXME: Replication factor should be configurable
|
||||
self.cassandra.execute(f"""
|
||||
create keyspace if not exists {self.keyspace}
|
||||
with replication = {{
|
||||
'class' : 'SimpleStrategy',
|
||||
'replication_factor' : 1
|
||||
'replication_factor' : {self.replication_factor}
|
||||
}};
|
||||
""");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue